Skip to content

Commit

Permalink
put state:modified.vars behind behaviour flag
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelleArk committed Sep 30, 2024
1 parent 91fbe7f commit 1422944
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
15 changes: 12 additions & 3 deletions core/dbt/contracts/graph/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,10 @@ def same_contract(self, old, adapter_type=None) -> bool:
return True

def same_vars(self, old) -> bool:
return self.vars == old.vars
if get_flags().state_modified_compare_vars:
return self.vars == old.vars
else:
return True

def same_contents(self, old, adapter_type) -> bool:
if old is None:
Expand Down Expand Up @@ -1256,7 +1259,10 @@ def same_config(self, old: "SourceDefinition") -> bool:
)

def same_vars(self, other: "SourceDefinition") -> bool:
return self.vars == other.vars
if get_flags().state_modified_compare_vars:
return self.vars == other.vars
else:
return True

def same_contents(self, old: Optional["SourceDefinition"]) -> bool:
# existing when it didn't before is a change!
Expand Down Expand Up @@ -1376,7 +1382,10 @@ def same_config(self, old: "Exposure") -> bool:
)

def same_vars(self, old: "Exposure") -> bool:
return self.vars == old.vars
if get_flags().state_modified_compare_vars:
return self.vars == old.vars
else:
return True

def same_contents(self, old: Optional["Exposure"]) -> bool:
# existing when it didn't before is a change!
Expand Down
2 changes: 2 additions & 0 deletions core/dbt/contracts/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ class ProjectFlags(ExtensibleDbtClassMixin):
require_resource_names_without_spaces: bool = False
source_freshness_run_project_hooks: bool = False
state_modified_compare_more_unrendered_values: bool = False
state_modified_compare_vars: bool = False

@property
def project_only_flags(self) -> Dict[str, Any]:
Expand All @@ -350,6 +351,7 @@ def project_only_flags(self) -> Dict[str, Any]:
"require_resource_names_without_spaces": self.require_resource_names_without_spaces,
"source_freshness_run_project_hooks": self.source_freshness_run_project_hooks,
"state_modified_compare_more_unrendered_values": self.state_modified_compare_more_unrendered_values,
"state_modified_compare_vars": self.state_modified_compare_vars,
}


Expand Down
9 changes: 9 additions & 0 deletions tests/functional/defer_state/test_modified_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,9 @@ class TestModifiedVars(BaseModifiedState):
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"flags": {
"state_modified_compare_vars": True,
},
"vars": {"my_var": 1},
}

Expand Down Expand Up @@ -1198,6 +1201,9 @@ class TestModifiedMacroVars(BaseModifiedState):
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"flags": {
"state_modified_compare_vars": True,
},
"vars": {"my_var": 1},
}

Expand Down Expand Up @@ -1261,6 +1267,9 @@ class TestModifiedVarsSchemaYml(BaseModifiedState):
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"flags": {
"state_modified_compare_vars": True,
},
"vars": {"my_var": "table"},
}

Expand Down

0 comments on commit 1422944

Please sign in to comment.