-
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
[Bug] [false positive] incremental_predicates
config causing model to show in state:modified
without changes
#10968
Comments
Thanks for reaching out @james-ho-cko ! We've been addressing some case of false positives within #9562. Did you happen to try installing dbt-core 1.9.0b3 and see if it still has the issue or not? For |
Thanks for getting back to me Doug, the epic you shared is really helpful.
to |
|
I tried to replicate the scenario that you reported using dbt v1.6, but I wasn't able. Could you try tweaking the file and commands below to replicate your bug report? Create this file:
{{
config(
materialized = 'incremental',
unique_key = 'id',
incremental_strategy = 'merge',
incremental_predicates = ["DBT_INTERNAL_DEST.ingestion_timestamp::date <= '" ~ var('date_parameter', modules.datetime.datetime.now()) ~ "'::date"],
)
}}
select 1 as id, {{ dbt.current_timestamp() }} as ingestion_timestamp Run these commands: dbt compile
mv target/manifest.json .
dbt list -s state:modified --state . I got this output:
|
I think you need to change branch. What we have is a model already in production with this predicate setup, and every time when we run CI on feature branch against the main branch's manifest, the model will show up even it's untouched. It's a bit inconsistent when I try to replicate it locally by
This might now work as it's the same file you created locally. I think it needs to be a model that's already in 2 different branches. |
@dbeatty10 try this: Create this file:
{{
config(
materialized = 'incremental',
unique_key = 'id',
incremental_strategy = 'merge',
incremental_predicates = ["DBT_INTERNAL_DEST.ingestion_timestamp::date <= '" ~ var('date_parameter', modules.datetime.datetime.now()) ~ "'::date"],
)
}}
select 1 as id, {{ dbt.current_timestamp() }} as ingestion_timestamp Run these commands:
Delete the model file(keep the manifest at current directory) Switch to another branch
Create a file with the same name and the exactly same contents: {{
config(
materialized = 'incremental',
unique_key = 'id',
incremental_strategy = 'merge',
incremental_predicates = ["DBT_INTERNAL_DEST.ingestion_timestamp::date <= '" ~ var('date_parameter', modules.datetime.datetime.now()) ~ "'::date"],
)
}}
select 1 as id, {{ dbt.current_timestamp() }} as ingestion_timestamp Run
This should give you |
@james-ho-cko I tried the steps you outlined, but I still wasn't able to replicate what you are reporting with I can see that the
As an aside, I wouldn't expect changing branches to make a difference either way as it relates to Are you able to replicate the issue without changing branches? |
Hey Doug, sorry for the late reply.
This should give you It also worked after waiting for a few minutes before generating the manifest file again for comparing, feels like a caching thing. |
Awesome @james-ho-cko ! Those commands helped me reliably replicate what you are saying. And here's an even more brief way that gave me dbt parse --target-path artifacts
dbt list --select state:modified --state artifacts |
However, if the same value is used for dbt parse --target-path artifacts --vars '{"date_parameter": "2024-01-01"}'
dbt list --select state:modified --state artifacts --vars '{"date_parameter": "2024-01-01"}' |
The underlying explantation seems to be that Good news: starting in dbt-core v1.9, setting the ExampleThe example below shows that the observed vs. expected behavior isn't due to using
{{
config(
materialized = 'table',
)
}}
select 1 as id, {{ dbt.string_literal(invocation_id) }} as invocation_id
{{
config(
materialized = 'incremental',
unique_key = 'id',
incremental_strategy = 'append',
incremental_predicates = ["DBT_INTERNAL_DEST.invocation_id = '" ~ invocation_id ~ "'"],
)
}}
select 1 as id, {{ dbt.string_literal(invocation_id) }} as invocation_id Run these commands: dbt parse --target-path artifacts
dbt list --select state:modified --state artifacts You'll see that But if you set the
SummaryClosing this as resolved by #10487 and/or #10675. @james-ho-cko could you let us know if you try this in dbt-core v1.9 with the |
incremental_predicates
config causing model to show in state:modified
without changes
Is this a new bug in dbt-core?
Current Behavior
I have some models with incremental predicate that looks back n days only. Something like
What we're noticing is the python module would render an actual value in the manifest file, which means the timestamp could change without the model being modified. This is causing issue cause the
state:modified
would pick up all models with this predicate.Expected Behavior
We would expect the manifest to be unchanged and the models with this setup wouldn't be flagged as changed when running
state:modified
Steps To Reproduce
module.datetime.datetime.now()
in it.mv ..../target/manifest.json .
dbt ls -m state:modified.body --state .
to compare the 2 branches. It shouldn't show anything as we didn't change any model, but the model with this predicate would show up. Looking into the 2 manifest files can see the timestamps in the incremental predicate are differentRelevant log output
No response
Environment
Which database adapter are you using with dbt?
snowflake
Additional Context
No response
The text was updated successfully, but these errors were encountered: