-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
BigQuery insert_overwrite incremental strategy fails for day partitioned tables #3095
Comments
We've experienced this same behavior. I'd note that this isn't a problem in 0.18.1., where the query used to create the struct returned dates rather than timestamps. |
Thanks for the report @osusam28 @noahbruegmann! This is a regression in v0.19.0, an unintended side-effect of the addition of In any case, we'll get this fixed for v0.19.1. We also need better test coverage for the matrix of potential partition data types and incremental strategies, to avoid regressions like this one (or #3063) from happening in the future. |
Great news: BigQuery considers a table to be partitioned by I'll work on a PR for this now. |
Don't know if this is related, but "granularity" fails in Dbt Cloud. Why is that? Could not parse partition config: at path []: Additional properties are not allowed ('granularity' was unexpected) |
@funnel-arvid Are you using dbt v0.19.0? Could you share the snippet of code (in |
@jtcohen6 Oh gosh, I just now realised you can choose and change the dbt version in cloud under your environment. I was on 0.17.0. Sorry for nothing! |
Description
I have a config for a model (using BigQuery) like below (in the model file):
ETL_CREATE_DTS is of the type TIMESTAMP
When running this model the first time (
dbt run
), it succeeds. However the second time, when the query is referencing the target table to find out what partitions to overwrite, it fails with the error:Turns out the generated SQL for this insert_overwrite is incorrect:
Notice the variable
declare dbt_partitions_for_replacement array<date>;
will not match the output of (2) becausetimestamp_trunc
returns a TIMESTAMP type.Steps To Reproduce
In as much detail as possible, please provide steps to reproduce the issue. Sample data that triggers the issue, example model code, etc is all very helpful here.
Expected behavior
I should be able to declare a BigQuery table partitioned by day on a timestamp field, and the insert_overwrite strategy work.
A quick fix in the code seems to be the declared variable needs to have the same datatype defined for the array as the data type of the partitioned field in the BigQuery table (see below)
It looks as if this line (https:/fishtown-analytics/dbt/blob/2b48152da66dbd7f07272983bbc261f1b6924f20/plugins/bigquery/dbt/include/bigquery/macros/materializations/incremental.sql#L20) could be removed to allow the the variable definition (https:/fishtown-analytics/dbt/blob/2b48152da66dbd7f07272983bbc261f1b6924f20/plugins/bigquery/dbt/include/bigquery/macros/materializations/incremental.sql#L52) to reflect the exact data type.
System information
Which database are you using dbt with?
The output of
dbt --version
:The operating system you're using:
macOS Catalina
The output of
python --version
:Python 2.7.16
The text was updated successfully, but these errors were encountered: