diff --git a/google/cloud/bigquery/client.py b/google/cloud/bigquery/client.py index b03266528..af8eaf5a7 100644 --- a/google/cloud/bigquery/client.py +++ b/google/cloud/bigquery/client.py @@ -266,6 +266,17 @@ def location(self): """Default location for jobs / datasets / tables.""" return self._location + @property + def default_query_job_config(self): + """Default ``QueryJobConfig``. + Will be merged into job configs passed into the ``query`` method. + """ + return self._default_query_job_config + + @default_query_job_config.setter + def default_query_job_config(self, value: QueryJobConfig): + self._default_query_job_config = copy.deepcopy(value) + def close(self): """Close the underlying transport objects, releasing system resources. diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index 22f7286db..f38874843 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -413,6 +413,19 @@ def test__get_query_results_hit(self): self.assertEqual(query_results.total_rows, 10) self.assertTrue(query_results.complete) + def test_default_query_job_config(self): + from google.cloud.bigquery import QueryJobConfig + + creds = _make_credentials() + http = object() + client = self._make_one(project=self.PROJECT, credentials=creds, _http=http) + self.assertIsNone(client.default_query_job_config) + + job_config = QueryJobConfig() + job_config.dry_run = True + client.default_query_job_config = job_config + self.assertIsInstance(client.default_query_job_config, QueryJobConfig) + def test_get_service_account_email(self): path = "/projects/%s/serviceAccount" % (self.PROJECT,) creds = _make_credentials()