diff --git a/core/dbt/contracts/graph/nodes.py b/core/dbt/contracts/graph/nodes.py index 731a5c53b48..6c589f11cf5 100644 --- a/core/dbt/contracts/graph/nodes.py +++ b/core/dbt/contracts/graph/nodes.py @@ -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: @@ -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! @@ -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! diff --git a/core/dbt/contracts/project.py b/core/dbt/contracts/project.py index e08131ecd8f..198b6c6325b 100644 --- a/core/dbt/contracts/project.py +++ b/core/dbt/contracts/project.py @@ -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]: @@ -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, } diff --git a/tests/functional/defer_state/test_modified_state.py b/tests/functional/defer_state/test_modified_state.py index 13af62c8e82..2fe52584b51 100644 --- a/tests/functional/defer_state/test_modified_state.py +++ b/tests/functional/defer_state/test_modified_state.py @@ -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}, } @@ -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}, } @@ -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"}, }