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

Adding caveat to the false positives #6207

Merged
merged 13 commits into from
Oct 2, 2024
Merged
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ dbt will mark modified any resource that depends on a changed macro, or on a mac

### Vars

If a model uses a `var` or `env_var` in its definition, dbt is unable today to identify that lineage in such a way that it can include the model in `state:modified` because the `var` or `env_var` value has changed. It's likely that the model will be marked modified if the change in variable results in a different configuration.
<VersionBlock lastVersion="1.8">

If a model uses a `var` or `env_var` in its definition, dbt Core 1.8 and earlier are unable today to identify that lineage in such a way that it can include the model in `state:modified` because the `var` or `env_var` value has changed. It's likely that the model will be marked modified if the change in variable results in a different configuration.
</VersionBlock>

<VersionBlock firstVersion="1.9">

Beginning in dbt Core 1.9, when you set the `state_modified_compare_vars` [behavior flag](/reference/global-configs/behavior-changes#behavior-change-flags) to `True` and a model uses a `var` or `env_var` in its definition, dbt will identify that lineage in such a way that it will include the model in `state:modified` when the `var` or `env_var` value has changed. Read more about the ["state" method](/reference/node-selection/methods#the-state-method).
graciegoheen marked this conversation as resolved.
Show resolved Hide resolved

</VersionBlock>

### Tests

Expand Down Expand Up @@ -44,12 +53,19 @@ dbt test -s "state:modified" --exclude "test_name:relationships"

### False positives

<VersionBlock firstVersion="1.9">

To reduce false positives during `state:modified` checks due to env-aware logic, you can set the `state_modified_compare_more_unrendered` [behavior flag](/reference/global-configs/behavior-changes#behavior-change-flags) to `True`.
graciegoheen marked this conversation as resolved.
Show resolved Hide resolved

</VersionBlock>

<VersionBlock lastVersion="1.8">
State comparison works by identifying discrepancies between two manifests. Those discrepancies could be the result of:

1. Changes made to a project in development
2. Env-aware logic that causes different behavior based on the `target`, env vars, etc.
2. Env-aware logic that causes different behavior based on the `target`, env vars, etc., which can be avoided if you upgrade to dbt Core 1.9 and set the `state_modified_compare_more_unrendered` [behavior flag](/reference/global-configs/behavior-changes#behavior-change-flags) to `True`.

State comparison detects env-aware config in `dbt_project.yml`. This target-based config registers as a modification:
State comparison detects env-aware config in `dbt_project.yml`. This target-based config won't register as a modification:

<File name='dbt_project.yml'>

Expand All @@ -73,6 +89,7 @@ That means the following config—functionally identical to the snippet above—
materialized = ('table' if target.name == 'prod' else 'view')
) }}
```
</VersionBlock>

### Final note

Expand Down
Loading