Skip to content

Commit

Permalink
feat: add set_default_query_job_config to client
Browse files Browse the repository at this point in the history
  • Loading branch information
chelsea-lin committed Mar 1, 2023
1 parent cd0aaa1 commit 6157096
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions google/cloud/bigquery/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 6157096

Please sign in to comment.