Skip to content

Commit fb8c802

Browse files
authored
Refactor QueryJob.query to read from resource dictionary (#7763)
This explicitly documents the QueryJob.query property and also aligns it with the other resource properties in the BigQuery client.
1 parent 11c854d commit fb8c802

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

  • bigquery/google/cloud/bigquery

bigquery/google/cloud/bigquery/job.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2357,7 +2357,10 @@ def __init__(self, job_id, query, client, job_config=None):
23572357
if job_config.use_legacy_sql is None:
23582358
job_config.use_legacy_sql = False
23592359

2360-
self.query = query
2360+
_helpers._set_sub_prop(
2361+
self._properties, ["configuration", "query", "query"], query
2362+
)
2363+
23612364
self._configuration = job_config
23622365
self._query_results = None
23632366
self._done_timeout = None
@@ -2424,6 +2427,17 @@ def priority(self):
24242427
"""
24252428
return self._configuration.priority
24262429

2430+
@property
2431+
def query(self):
2432+
"""str: The query text used in this query job.
2433+
2434+
See:
2435+
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.query
2436+
"""
2437+
return _helpers._get_sub_prop(
2438+
self._properties, ["configuration", "query", "query"]
2439+
)
2440+
24272441
@property
24282442
def query_parameters(self):
24292443
"""See
@@ -2516,7 +2530,6 @@ def to_api_repr(self):
25162530
def _copy_configuration_properties(self, configuration):
25172531
"""Helper: assign subclass configuration properties in cleaned."""
25182532
self._configuration._properties = copy.deepcopy(configuration)
2519-
self.query = _helpers._get_sub_prop(configuration, ["query", "query"])
25202533

25212534
@classmethod
25222535
def from_api_repr(cls, resource, client):

0 commit comments

Comments
 (0)