Skip to content

Commit

Permalink
Refactor QueryJob.query to read from resource dictionary (#7763)
Browse files Browse the repository at this point in the history
This explicitly documents the QueryJob.query property and also aligns it
with the other resource properties in the BigQuery client.
  • Loading branch information
tswast authored Apr 23, 2019
1 parent 11c854d commit fb8c802
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions bigquery/google/cloud/bigquery/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -2357,7 +2357,10 @@ def __init__(self, job_id, query, client, job_config=None):
if job_config.use_legacy_sql is None:
job_config.use_legacy_sql = False

self.query = query
_helpers._set_sub_prop(
self._properties, ["configuration", "query", "query"], query
)

self._configuration = job_config
self._query_results = None
self._done_timeout = None
Expand Down Expand Up @@ -2424,6 +2427,17 @@ def priority(self):
"""
return self._configuration.priority

@property
def query(self):
"""str: The query text used in this query job.
See:
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.query
"""
return _helpers._get_sub_prop(
self._properties, ["configuration", "query", "query"]
)

@property
def query_parameters(self):
"""See
Expand Down Expand Up @@ -2516,7 +2530,6 @@ def to_api_repr(self):
def _copy_configuration_properties(self, configuration):
"""Helper: assign subclass configuration properties in cleaned."""
self._configuration._properties = copy.deepcopy(configuration)
self.query = _helpers._get_sub_prop(configuration, ["query", "query"])

@classmethod
def from_api_repr(cls, resource, client):
Expand Down

0 comments on commit fb8c802

Please sign in to comment.