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

API not respecting destination table #1786

Closed
mattjo opened this issue May 11, 2016 · 5 comments
Closed

API not respecting destination table #1786

mattjo opened this issue May 11, 2016 · 5 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

@mattjo
Copy link

mattjo commented May 11, 2016

Following the example at https://googlecloudplatform.github.io/gcloud-python/stable/bigquery-usage.html#querying-data-asynchronous the destination table does not appear to be respected

Reproduction steps and observed behavior:

QUERY = 'SELECT * FROM [dataset.babynames] where name = "Beth"'
dataset = client.dataset('dataset')
table = dataset.table(name='only_beth')
job = client.run_async_query('only_beth', QUERY)
job.destination_table = table
job.write_disposition = 'WRITE_EMPTY'
job.begin()
job.reload()
job.state
'DONE'

Job has write_disposition: WRITE_TRUNCATE and destination table_id: "anon6f3505ba6efbcaaa685e4812bf5e132db2bb343a"

Expected behavior: Job should have created a new table called beth_only and set write disposition to WRITE_EMPTY

@jgeewax jgeewax added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. api: bigquery Issues related to the BigQuery API. labels May 11, 2016
@dhermes
Copy link
Contributor

dhermes commented May 11, 2016

You never called table.create(), though I'm surprised that this code worked since the destination table didn't exist. @tseaver Can you take a look?

@ToddMorrill
Copy link

Table creation shouldn't be an issue according this: https://cloud.google.com/bigquery/docs/reference/v2/jobs

configuration.copy.createDisposition

Default is: "CREATE_IF_NEEDED: If the table does not exist, BigQuery creates the table."

@dhermes
Copy link
Contributor

dhermes commented May 11, 2016

D'oh! My bad.

@tseaver
Copy link
Contributor

tseaver commented May 26, 2016

@ToddMorrill I cannot reproduce here: your example triggers an attribute error for job.destination_table (that attribute of the job was renamed back in December in commit ad57744).

When I correct it to job.destination, and run the job, the data is saved as expected in the newly-created table.

@ToddMorrill
Copy link

Much appreciated, looks like it's just a matter of documentation. See here, where it is still being called "job.destination_table" https://googlecloudplatform.github.io/gcloud-python/stable/bigquery-usage.html

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

5 participants