Skip to content

Commit

Permalink
Merge pull request #1834 from delfick/dry_run
Browse files Browse the repository at this point in the history
Dry Run for bigquery queries
  • Loading branch information
tseaver committed May 30, 2016
2 parents d8735e1 + 7b852b4 commit b27907b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions gcloud/bigquery/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class _SyncQueryConfiguration(object):
Values which are ``None`` -> server defaults.
"""
_default_dataset = None
_dry_run = None
_max_results = None
_timeout_ms = None
_preserve_nulls = None
Expand Down Expand Up @@ -207,6 +208,11 @@ def schema(self):
https://cloud.google.com/bigquery/docs/reference/v2/jobs/query#defaultDataset
"""

dry_run = _TypedProperty('dry_run', bool)
"""See:
https://cloud.google.com/bigquery/docs/reference/v2/jobs/query#dryRun
"""

max_results = _TypedProperty('max_results', six.integer_types)
"""See:
https://cloud.google.com/bigquery/docs/reference/v2/jobs/query#maxResults
Expand Down Expand Up @@ -258,6 +264,9 @@ def _build_resource(self):
if self.use_query_cache is not None:
resource['useQueryCache'] = self.use_query_cache

if self.dry_run is not None:
resource['dryRun'] = self.dry_run

return resource

def run(self, client=None):
Expand Down
2 changes: 2 additions & 0 deletions gcloud/bigquery/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def test_run_w_alternate_client(self):
query.preserve_nulls = True
query.timeout_ms = 20000
query.use_query_cache = False
query.dry_run = True

query.run(client=client2)

Expand All @@ -220,6 +221,7 @@ def test_run_w_alternate_client(self):
'projectId': self.PROJECT,
'datasetId': DATASET,
},
'dryRun': True,
'maxResults': 100,
'preserveNulls': True,
'timeoutMs': 20000,
Expand Down

0 comments on commit b27907b

Please sign in to comment.