Repository: dbt-labs/dbt-core

Issue:
Bug: Overly verbose info-level logging for BigQuery queries that 404
### Describe the bug
I noticed this while reviewing https://github.com/fishtown-analytics/dbt/pull/2378 -- when the catalog query failed with a 404 error, I saw the entire contents of the catalog query printed to stdout. Instead, the verbose BQ-generated error message should be logged to the debug logs.

### Steps To Reproduce
This happens for both `dbt run` and `dbt docs generate`, and probably others too

1. Set your `location` to `US` in your BQ profile
2. Do a `dbt run` that creates at least one model in the db
3. Change your `location` to `northamerica-northeast1`
4. Run `dbt run` again and observe the stdout

### Expected behavior
Stdout should not include the entire contents of the query that failed

**The output of `dbt --version`:**
```
dev/octavius-catto
```


Discussion:

Resolving patch:
diff --git a/plugins/bigquery/dbt/adapters/bigquery/connections.py b/plugins/bigquery/dbt/adapters/bigquery/connections.py
--- a/plugins/bigquery/dbt/adapters/bigquery/connections.py
+++ b/plugins/bigquery/dbt/adapters/bigquery/connections.py
@@ -20,6 +20,9 @@
 from hologram.helpers import StrEnum
 
 
+BQ_QUERY_JOB_SPLIT = '-----Query Job SQL Follows-----'
+
+
 class Priority(StrEnum):
     Interactive = 'interactive'
     Batch = 'batch'
@@ -95,7 +98,12 @@ def exception_handler(self, sql):
                 # this sounds a lot like a signal handler and probably has
                 # useful information, so raise it without modification.
                 raise
-            raise RuntimeException(str(e))
+            exc_message = str(e)
+            # the google bigquery library likes to add the query log, which we
+            # don't want to log. Hopefully they never change this!
+            if BQ_QUERY_JOB_SPLIT in exc_message:
+                exc_message = exc_message.split(BQ_QUERY_JOB_SPLIT)[0].strip()
+            raise RuntimeException(exc_message)
 
     def cancel_open(self) -> None:
         pass


Test patch:
diff --git a/test/integration/022_bigquery_test/location-models/model.sql b/test/integration/022_bigquery_test/location-models/model.sql
new file mode 100644
--- /dev/null
+++ b/test/integration/022_bigquery_test/location-models/model.sql
@@ -0,0 +1 @@
+select 1 as id
diff --git a/test/integration/022_bigquery_test/test_bigquery_location_change.py b/test/integration/022_bigquery_test/test_bigquery_location_change.py
new file mode 100644
--- /dev/null
+++ b/test/integration/022_bigquery_test/test_bigquery_location_change.py
@@ -0,0 +1,31 @@
+from test.integration.base import DBTIntegrationTest, use_profile
+import os
+
+
+class TestBigqueryErrorHandling(DBTIntegrationTest):
+    def setUp(self):
+        self.valid_location = os.getenv('DBT_TEST_BIGQUERY_INITIAL_LOCATION', 'US')
+        self.invalid_location = os.getenv('DBT_TEST_BIGQUERY_BAD_LOCATION', 'northamerica-northeast1')
+        self.location = self.valid_location
+        super().setUp()
+
+    @property
+    def schema(self):
+        return "bigquery_test_022"
+
+    @property
+    def models(self):
+        return "location-models"
+
+    def bigquery_profile(self):
+        result = super().bigquery_profile()
+        result['test']['outputs']['default2']['location'] = self.location
+        return result
+
+    @use_profile('bigquery')
+    def test_bigquery_location_invalid(self):
+        self.run_dbt()
+        self.location = self.invalid_location
+        self.use_profile('bigquery')
+        _, stdout = self.run_dbt_and_capture(expect_pass=False)
+        assert 'Query Job SQL Follows' not in stdout