-
Notifications
You must be signed in to change notification settings - Fork 234
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
[ADAP-946] [CT-2689] [Bug] Incremental models ran from scratch when created in a pre-hook #918
Comments
Thanks for opening this @jelstongreen ! Before we get into the details of this bug report, you might be interested in subscribing to dbt-labs/dbt-core#7256 since the big idea in that feature is:
Reproducing thisCould you help me reproduce this by supplying example model .sql file(s) (and any related YAML configuration files)? And also the commands to trigger the error? i.e., something like this:
{{ config(
materialized='incremental',
pre_hook="SQL-statement",
...
) }}
select ...
# anything applicable from a dbt_project.yml file here
# anything applicable from a (model) properties file here Commands: dbt build --full-refresh
dbt run --select my_incremental_model |
Hi @dbeatty10. Here you go:
shallow_clone_production.sql
command
|
Given that this is being looked at for 1.6 I imagine this isn't going to be a priority. I can create a workaround in the meantime and run the macro as an operation in a step for invoking dbt unless this is something you'd like to look at. |
Thanks for that example @jelstongreen -- that helps me see exactly what is going on. When you invoke dbt like
So you can see from the above how the error follows:
Running a macro as an operation is a good workaround until v1.6 comes out. Another option you could try if you are so inclined:
|
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days. |
Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers. |
can we check the status of this please? |
@amyfeng-klaviyo we've closed this issue since we didn't find any bug within dbt-core to fix. If you think you're experiencing a bug within dbt-core, could you open a new issue here and describe it in detail so we can try to reproduce it? If you have a substantially similar use-case as jelstongreen described here, then I'd suggest one of the following:
|
@dbeatty10 thanks for the update! my question is really the same as the bug described above.
|
Is this a new bug in dbt-core?
Current Behavior
When running incremental models in a dev / ci environment I am trying to shallow clone the production tables into the dev schema to fully simulate how the changes might affect the production model. Unfortunately whether a model should be run with
is_incremental
or not is determined at compile time, before the pre-hook creating the dev version of the model is run. This leads to dbt running the dev model from scratch even though it already exists.Expected Behavior
Ideally, the check for whether to run the model in incremental mode or not should be executed at runtime.
Steps To Reproduce
Opened a fresh branch which will execute tables in branch db. Run the model and it executes:
pre-hook:
model:
If I then cancel that query and rerun dbt:
pre-hook:
model:
The only difference between the two runs is that the dev version of the model (the clone) exists in the 2nd one at compile time.
Relevant log output
No response
Environment
Which database adapter are you using with dbt?
spark, other (mention it in "Additional Context")
Additional Context
Databricks
The text was updated successfully, but these errors were encountered: