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

view.query property not exposed by Bigquery API #3754

Closed
nicku33 opened this issue Aug 8, 2017 · 5 comments
Closed

view.query property not exposed by Bigquery API #3754

nicku33 opened this issue Aug 8, 2017 · 5 comments
Assignees
Labels
api: bigquery Issues related to the BigQuery API.

Comments

@nicku33
Copy link

nicku33 commented Aug 8, 2017

OS X 10
Python 2.7.10
Name: google-cloud Version: 0.24.0

To reproduce, make a view. In our case it was existing.
! bq show --format=json nytdata:audit_et.audit_ab_alloc_view

Note that the property view.query is present in the json:

{"kind":"bigquery#table","creationTime":"1471555852846",
...
"view":{"query":"with date_range a ... REDACTED ...",
"useLegacySql":false},"type":"VIEW","id":"nytdata:audit_et.audit_ab_alloc_view","selfLink":"https://www.googleapis.com/bigquery/v2/projects/nytdata/datasets/audit_et/tables/audit_ab_alloc_view","
...
}

But if I try to get it from the API, nothing:

from google.cloud import bigquery

project="nytdata"
dataset="audit_et"
table="audit_ab_alloc_view"

bigquery_client = bigquery.Client(project=project)
dataset_temp = bigquery_client.dataset(dataset)
t=dataset_temp.table(table)
t=dataset_temp.table(u'audit_ab_alloc_view')

t.exists()
>> True

t.view_query == None
>> True
@dhermes dhermes added the api: bigquery Issues related to the BigQuery API. label Aug 8, 2017
@lukesneeringer lukesneeringer added priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Aug 8, 2017
@lukesneeringer
Copy link
Contributor

@tseaver Is this something that can reasonably be done alongside #3746?

@lukesneeringer lukesneeringer removed the priority: p2 Moderately-important priority. Fix may not be included in next release. label Aug 9, 2017
@tseaver
Copy link
Contributor

tseaver commented Aug 10, 2017

@nicku33 Can you try running t.reload() and see if the view_query is populated? We don't automagically fetch the server-side properties when creating the client-side table instance.

@nicku33
Copy link
Author

nicku33 commented Aug 10, 2017

Oh wow, that worked. I suppose I assumed that
dataset_temp.table( TABLE_NAME )
did an API fetch. Did I miss something in docs ?

@tseaver tseaver added docs and removed type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Aug 10, 2017
@tseaver
Copy link
Contributor

tseaver commented Aug 10, 2017

@nicku33 I agree that the docs don't highlight it, but we explicitly avoid making back-end API calls during instance construction.

@lukesneeringer
Copy link
Contributor

Something @tswast recommends elsewhere is that we make it such that the first time you do a call or property check that would require this, that we just do the .reload behind the scenes.

I am going to actually close this since that is tracked elsewhere.

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.
Projects
None yet
Development

No branches or pull requests

4 participants