Uh oh!
There was an error while loading. Please reload this page.
Fix new partitioned table - #3381
Conversation
…w-partitioned-table
[This is a re-do of the pull request googleapis#3366 to fix the author email address to use my google.com email] I moved the partitioning_type check into the if/elif block to avoid a ValueError that should not have been thrown. See: https://cloud.google.com/bigquery/docs/creating-partitioned-tables#creat ing_a_partitioned_table and the "API" example. Before my change, the following code failed with the ValueError thrown by this function, but with my change, I was able to successfully create the partitioned table: destination_table = dataset.table(table_shortname) destination_partition = dataset.table(table_shortname+'$'+partition_date) if not destination_table.exists(): destination_table.partitioning_type = 'DAY' destination_table.create()
richkadel
commented
May 6, 2017
@dhermes@jonparrott |
dhermes
commented
May 8, 2017
Thanks @richkadel. This LGTM. @tswast Any issues? |
dhermes
commented
May 8, 2017
@richkadel Your code snippet above never uses |
| raise ValueError("Set either 'view_query' or 'schema'.") | ||
| elif self.partitioning_type is None: | ||
| raise ValueError( | ||
| "Set either 'view_query' or 'schema' or 'partitioning_type'.") |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
richkadel
commented
May 8, 2017
@dhermes re: @richkadel Your code snippet above never uses destination_partition. Is there a typo somewhere? No typo. The code that uses the partition itself is not shown. I left the line in to show that the table name used in the "create" call is the table name without the partition suffix. Once the table is created then you can use destination_partition value as the "job_destination" setting to materialize data into just that partition. |
dhermes
commented
May 8, 2017
@richkadel Gotcha, I just made an edit to make that clearer. |
As discussed with team, I removed the ValueError and any assumptions about the legitimate combinations of values in the request. ValueError unit test was removed, and the unused schema in `test_create_w_alternate_client` that was suppressed due to the `elif` in `_build_resource`, was removed so the expected value still matches the remaining inputs.
richkadel
commented
May 9, 2017
Updates have been pushed and all tests pass. |
dhermes
commented
May 9, 2017
OK @jonparrott also thinks this looks just fine. |
[This is a re-do of the pull request #3366 to fix the author email address to use my
google.comemail]I moved the
partitioning_typecheck into theif/elifblock to avoid aValueErrorthat should not have been thrown.See:
https://cloud.google.com/bigquery/docs/creating-partitioned-tables#creating_a_partitioned_table and the "API" example.
Before my change, the following code failed with the
ValueErrorthrown by this function, but with my change, I was able to successfully create the partitioned table: