Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor QueryJob.query to read from resource dictionary #7763

Merged
merged 1 commit into from
Apr 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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