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

state:modified vars, behind "state_modified_compare_vars" behaviour flag #10793

Merged
merged 14 commits into from
Sep 30, 2024

Conversation

MichelleArk
Copy link
Contributor

@MichelleArk MichelleArk commented Sep 30, 2024

Resolves #4304

Problem

With #10675, we removed the capability for dbt to (sometimes) detect changes in vars as modifying models/dbt resources that depended on them (behind a behaviour flag).

Solution

This behaviour is actually desired (distinction between env_var and var), so let's introduce state:modified.vars as a standalone selector method as well as a default. This is also behind a behaviour flag in case existing users rely on the current var state:modified selection behaviour (flawed as it is!).

Checklist

  • I have read the contributing guide and understand what's expected of me.
  • I have run this code in development, and it appears to resolve the stated issue.
  • This PR includes tests, or tests are not required or relevant for this PR.
  • This PR has no interface changes (e.g., macros, CLI, logs, JSON artifacts, config files, adapter interface, etc.) or this PR has already received feedback and approval from Product or DX.
  • This PR includes type annotations for new and modified functions.

@cla-bot cla-bot bot added the cla:yes label Sep 30, 2024
@MichelleArk MichelleArk added the artifact_minor_upgrade To bypass the CI check by confirming that the change is not breaking label Sep 30, 2024
@MichelleArk MichelleArk changed the title State modified vars state:modified vars Sep 30, 2024
@MichelleArk MichelleArk changed the title state:modified vars state:modified vars, behind state_modified_compare_vars Sep 30, 2024
@MichelleArk MichelleArk changed the title state:modified vars, behind state_modified_compare_vars state:modified vars, behind "state_modified_compare_vars" behaviour flag Sep 30, 2024
@MichelleArk MichelleArk mentioned this pull request Sep 30, 2024
5 tasks
Copy link

codecov bot commented Sep 30, 2024

Codecov Report

Attention: Patch coverage is 98.61111% with 1 line in your changes missing coverage. Please review.

Project coverage is 89.20%. Comparing base (5e3d418) to head (093be30).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10793      +/-   ##
==========================================
+ Coverage   89.16%   89.20%   +0.04%     
==========================================
  Files         183      183              
  Lines       23258    23344      +86     
==========================================
+ Hits        20738    20825      +87     
+ Misses       2520     2519       -1     
Flag Coverage Δ
integration 86.50% <98.61%> (+0.04%) ⬆️
unit 62.17% <52.77%> (-0.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Unit Tests 62.17% <52.77%> (-0.12%) ⬇️
Integration Tests 86.50% <98.61%> (+0.04%) ⬆️

@jtcohen6 jtcohen6 added the user docs [docs.getdbt.com] Needs better documentation label Sep 30, 2024
@MichelleArk
Copy link
Contributor Author

Associated schemas PR: dbt-labs/schemas.getdbt.com#64

@MichelleArk MichelleArk marked this pull request as ready for review September 30, 2024 13:24
@MichelleArk MichelleArk requested review from a team as code owners September 30, 2024 13:24
@MichelleArk MichelleArk requested review from wpowers-dbt and removed request for a team September 30, 2024 13:24
@@ -58,19 +70,21 @@ def __call__(self, var_name, default=Var._VAR_NOTSET):
all_vars.add(my_config.vars.vars_for(lookup, adapter_type))
all_vars.add(active_vars)

if var_name in all_vars:
return all_vars[var_name]
if not var_found and var_name in all_vars:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This refactor was primarily for the happiness of our linting tools. There was no final return statement on the method in the past.

@MichelleArk MichelleArk merged commit d1857b3 into main Sep 30, 2024
65 of 66 checks passed
@MichelleArk MichelleArk deleted the state-modified-vars branch September 30, 2024 14:32
aranke added a commit that referenced this pull request Oct 2, 2024
aranke added a commit that referenced this pull request Oct 2, 2024
QMalcolm added a commit to dbt-labs/schemas.getdbt.com that referenced this pull request Oct 12, 2024
Originally this work was done as part of #49.
However as they are additive fields that have a default values, they aren't
breaking changes. Thus here we're adding them to the v12 manifest. This is
in support of the currently open dbt-core PR dbt-labs/dbt-core#10532.

Note this also _drops_ the `vars` field from a few objects. It was originally added
to support changes in core (dbt-labs/dbt-core#10793). However,
those changes were reverted in core (dbt-labs/dbt-core#10813).
Since `vars` as a field never went out in a GA release of dbt-core, it is safe for us
to drop it.
QMalcolm added a commit to dbt-labs/schemas.getdbt.com that referenced this pull request Oct 15, 2024
Originally this work was done as part of #49.
However as they are additive fields that have a default values, they aren't
breaking changes. Thus here we're adding them to the v12 manifest. This is
in support of the currently open dbt-core PR dbt-labs/dbt-core#10532.

Note this also _drops_ the `vars` field from a few objects. It was originally added
to support changes in core (dbt-labs/dbt-core#10793). However,
those changes were reverted in core (dbt-labs/dbt-core#10813).
Since `vars` as a field never went out in a GA release of dbt-core, it is safe for us
to drop it.
QMalcolm added a commit to dbt-labs/schemas.getdbt.com that referenced this pull request Oct 15, 2024
Originally this work was done as part of #49.
However as they are additive fields that have a default values, they aren't
breaking changes. Thus here we're adding them to the v12 manifest. This is
in support of the currently open dbt-core PR dbt-labs/dbt-core#10532.

Note this also _drops_ the `vars` field from a few objects. It was originally added
to support changes in core (dbt-labs/dbt-core#10793). However,
those changes were reverted in core (dbt-labs/dbt-core#10813).
Since `vars` as a field never went out in a GA release of dbt-core, it is safe for us
to drop it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
artifact_minor_upgrade To bypass the CI check by confirming that the change is not breaking cla:yes user docs [docs.getdbt.com] Needs better documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[vars] [false negatives] Changes in used variables do not cause models to be selected by state:modified
3 participants