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

Expose SQL query in QueryJob API #2511

Closed
aaronkavlie-wf opened this issue Oct 6, 2016 · 6 comments
Closed

Expose SQL query in QueryJob API #2511

aaronkavlie-wf opened this issue Oct 6, 2016 · 6 comments
Assignees
Labels
api: bigquery Issues related to the BigQuery API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@aaronkavlie-wf
Copy link

I had a need to reference the original SQL query from a job. After running job.reload() it's available on a QueryJob instance, but only by reaching into _properties directly:

query = job._properties['configuration']['query']['query']

it should be exposed under a more direct public property.

@dhermes dhermes added api: bigquery Issues related to the BigQuery API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Oct 6, 2016
@tseaver tseaver added docs and removed type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Oct 7, 2016
@tseaver
Copy link
Contributor

tseaver commented Oct 7, 2016

The job actually has a query attribute, holding the query text: we need to surface it to the documentation side, however.

@dhermes
Copy link
Contributor

dhermes commented Oct 7, 2016

@tseaver Similar to #1835 (comment)

@tseaver
Copy link
Contributor

tseaver commented Oct 7, 2016

@dhermes I knew there was another issue about those kind of public-but-undocumented attrs.

@dhermes
Copy link
Contributor

dhermes commented Oct 7, 2016

There's also #2034

@aaronkavlie-wf
Copy link
Author

@tseaver

The job actually has a query attribute, holding the query text

Yes, that's the first thing I tried. It's None for me. I'm initializing the QueryJob from a job ID:

    job = bigquery.job.QueryJob(job_id, None, bigquery.Client())
    job.reload()

It doesn't seem like that class is intended for API users to call directly (especially since it takes the query string as an input), so if there's a better way to do this let me know.

@tseaver tseaver added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed docs labels Oct 7, 2016
@tseaver
Copy link
Contributor

tseaver commented Oct 7, 2016

Thanks for the followup: job.query should definitely be populated after job.reload().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the BigQuery API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants