From 99998a597c75d71f85b85202e31de6cff984249e Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Mon, 15 Apr 2024 23:19:38 -0700 Subject: [PATCH 1/8] first pass: flags.allow_materialization_overrides --- core/dbt/contracts/graph/manifest.py | 17 ++++++++++++++++- core/dbt/contracts/project.py | 5 +++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/core/dbt/contracts/graph/manifest.py b/core/dbt/contracts/graph/manifest.py index 852f4dce724..15834dd2e59 100644 --- a/core/dbt/contracts/graph/manifest.py +++ b/core/dbt/contracts/graph/manifest.py @@ -906,6 +906,21 @@ def _materialization_candidates_for( adapter_type: str, specificity: int, ) -> CandidateList: + + # Do not include imported macros in materialization macro candidates + def filter(candidate: MacroCandidate) -> bool: + flags = get_flags() + # legacy behaviour - allow materialization overrides from packages + if flags.allow_materialization_overrides is None: + # TODO: fire deprecation event + return True + else: + return ( + candidate.macro.package_name in flags.allow_materialization_overrides + if candidate.locality == Locality.Imported + else True + ) + full_name = dbt_common.utils.get_materialization_macro_name( materialization_name=materialization_name, adapter_type=adapter_type, @@ -913,7 +928,7 @@ def _materialization_candidates_for( ) return CandidateList( MaterializationCandidate.from_macro(m, specificity) - for m in self._find_macros_by_name(full_name, project_name) + for m in self._find_macros_by_name(full_name, project_name, filter=filter) ) def find_materialization_macro_by_name( diff --git a/core/dbt/contracts/project.py b/core/dbt/contracts/project.py index 46c9742952f..4616fd9e2d7 100644 --- a/core/dbt/contracts/project.py +++ b/core/dbt/contracts/project.py @@ -297,6 +297,10 @@ def validate(cls, data): @dataclass class ProjectFlags(ExtensibleDbtClassMixin): allow_spaces_in_model_names: Optional[bool] = True + # None => default, allow from all (default behaviour) + # ["dbt_utils"] => only allow from these packages + # [] => allow from none, will be new default behaviour + allow_materialization_overrides: Optional[List[str]] = None cache_selected_only: Optional[bool] = None debug: Optional[bool] = None fail_fast: Optional[bool] = None @@ -324,6 +328,7 @@ def project_only_flags(self) -> Dict[str, Any]: return { "source_freshness_run_project_hooks": self.source_freshness_run_project_hooks, "allow_spaces_in_model_names": self.allow_spaces_in_model_names, + "allow_materialization_overrides": self.allow_materialization_overrides, } From 02e93d29f1448fd2ca71ad8dc2b22d7c99dfbbb4 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Mon, 22 Apr 2024 17:21:14 -0400 Subject: [PATCH 2/8] deprecate_package_materialization_builtin_override --- core/dbt/cli/flags.py | 2 +- core/dbt/contracts/graph/manifest.py | 51 +++++++++++++++------------- core/dbt/contracts/project.py | 7 ++-- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/core/dbt/cli/flags.py b/core/dbt/cli/flags.py index d87c1aa96eb..9d49d339543 100644 --- a/core/dbt/cli/flags.py +++ b/core/dbt/cli/flags.py @@ -355,7 +355,7 @@ def set_common_global_flags(self): # This is here to prevent mypy from complaining about all of the # attributes which we added dynamically. def __getattr__(self, name: str) -> Any: - return super().__get_attribute__(name) # type: ignore + return super().__getattribute__(name) # type: ignore CommandParams = List[str] diff --git a/core/dbt/contracts/graph/manifest.py b/core/dbt/contracts/graph/manifest.py index 6de4a6e7c35..20decafae15 100644 --- a/core/dbt/contracts/graph/manifest.py +++ b/core/dbt/contracts/graph/manifest.py @@ -571,11 +571,25 @@ def __lt__(self, other: object) -> bool: class CandidateList(List[M]): - def last_candidate(self) -> Optional[MacroCandidate]: + def last_candidate( + self, valid_localities: Optional[List[Locality]] = None + ) -> Optional[MacroCandidate]: + """ + Obtain the last (highest precedence) MacroCandidate from the CandidateList of any locality in valid_localities. + If valid_localities is not specified, return the last MacroCandidate of any locality. + """ if not self: return None self.sort() - return self[-1] + + if valid_localities is None: + return self[-1] + + for candidate in reversed(self): + if candidate.locality in valid_localities: + return candidate + + return None def last(self) -> Optional[Macro]: last_candidate = self.last_candidate() @@ -911,21 +925,6 @@ def _materialization_candidates_for( adapter_type: str, specificity: int, ) -> CandidateList: - - # Do not include imported macros in materialization macro candidates - def filter(candidate: MacroCandidate) -> bool: - flags = get_flags() - # legacy behaviour - allow materialization overrides from packages - if flags.allow_materialization_overrides is None: - # TODO: fire deprecation event - return True - else: - return ( - candidate.macro.package_name in flags.allow_materialization_overrides - if candidate.locality == Locality.Imported - else True - ) - full_name = dbt_common.utils.get_materialization_macro_name( materialization_name=materialization_name, adapter_type=adapter_type, @@ -933,7 +932,7 @@ def filter(candidate: MacroCandidate) -> bool: ) return CandidateList( MaterializationCandidate.from_macro(m, specificity) - for m in self._find_macros_by_name(full_name, project_name, filter=filter) + for m in self._find_macros_by_name(full_name, project_name) ) def find_materialization_macro_by_name( @@ -961,11 +960,17 @@ def find_materialization_macro_by_name( and materialization_candidate.locality == Locality.Imported and core_candidates ): - deprecations.warn( - "package-materialization-override", - package_name=materialization_candidate.macro.package_name, - materialization_name=materialization_name, - ) + # preserve legacy behaviour - allow materialization override + if get_flags().deprecate_package_materialization_builtin_override is False: + deprecations.warn( + "package-materialization-override", + package_name=materialization_candidate.macro.package_name, + materialization_name=materialization_name, + ) + else: + materialization_candidate = candidates.last_candidate( + valid_localities=[Locality.Core, Locality.Root] + ) return materialization_candidate.macro if materialization_candidate else None diff --git a/core/dbt/contracts/project.py b/core/dbt/contracts/project.py index 4616fd9e2d7..34fb8c50b97 100644 --- a/core/dbt/contracts/project.py +++ b/core/dbt/contracts/project.py @@ -297,12 +297,9 @@ def validate(cls, data): @dataclass class ProjectFlags(ExtensibleDbtClassMixin): allow_spaces_in_model_names: Optional[bool] = True - # None => default, allow from all (default behaviour) - # ["dbt_utils"] => only allow from these packages - # [] => allow from none, will be new default behaviour - allow_materialization_overrides: Optional[List[str]] = None cache_selected_only: Optional[bool] = None debug: Optional[bool] = None + deprecate_package_materialization_builtin_override: bool = False fail_fast: Optional[bool] = None indirect_selection: Optional[str] = None log_format: Optional[str] = None @@ -328,7 +325,7 @@ def project_only_flags(self) -> Dict[str, Any]: return { "source_freshness_run_project_hooks": self.source_freshness_run_project_hooks, "allow_spaces_in_model_names": self.allow_spaces_in_model_names, - "allow_materialization_overrides": self.allow_materialization_overrides, + "deprecate_package_materialization_builtin_override": self.deprecate_package_materialization_builtin_override, } From 3552c2a9a43fa78cd8323fa66e0b428e49b5f015 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Mon, 22 Apr 2024 17:30:46 -0400 Subject: [PATCH 3/8] add functional tests for deprecate_package_materialization_builtin_override --- .../test_custom_materialization.py | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/tests/functional/materializations/test_custom_materialization.py b/tests/functional/materializations/test_custom_materialization.py index dd165514ec1..b2410ed83ed 100644 --- a/tests/functional/materializations/test_custom_materialization.py +++ b/tests/functional/materializations/test_custom_materialization.py @@ -44,6 +44,56 @@ def test_adapter_dependency(self, project, override_view_adapter_dep, set_up_dep assert deprecations.active_deprecations == {"package-materialization-override"} +class TestOverrideAdapterDependencyDeprecated: + # make sure that if there's a dependency with an adapter-specific + # materialization, we honor that materialization + @pytest.fixture(scope="class") + def packages(self): + return {"packages": [{"local": "override-view-adapter-dep"}]} + + @pytest.fixture(scope="class") + def project_config_update(self): + return { + "flags": { + "deprecate_package_materialization_builtin_override": True, + }, + } + + def test_adapter_dependency_deprecate_overrides( + self, project, override_view_adapter_dep, set_up_deprecations + ): + run_dbt(["deps"]) + # this should pass because the override is buggy and unused + run_dbt(["run"]) + + # no deprecation warning -- flag used correctly + assert deprecations.active_deprecations == set() + + +class TestOverrideAdapterDependencyLegacy: + # make sure that if there's a dependency with an adapter-specific + # materialization, we honor that materialization + @pytest.fixture(scope="class") + def packages(self): + return {"packages": [{"local": "override-view-adapter-dep"}]} + + @pytest.fixture(scope="class") + def project_config_update(self): + return { + "flags": { + "deprecate_package_materialization_builtin_override": False, + }, + } + + def test_adapter_dependency(self, project, override_view_adapter_dep, set_up_deprecations): + run_dbt(["deps"]) + # this should error because the override is buggy + run_dbt(["run"], expect_pass=False) + + # overriding a built-in materialization scoped to adapter from package is deprecated + assert deprecations.active_deprecations == {"package-materialization-override"} + + class TestOverrideDefaultDependency: @pytest.fixture(scope="class") def packages(self): @@ -58,6 +108,52 @@ def test_default_dependency(self, project, override_view_default_dep, set_up_dep assert deprecations.active_deprecations == {"package-materialization-override"} +class TestOverrideDefaultDependencyDeprecated: + @pytest.fixture(scope="class") + def packages(self): + return {"packages": [{"local": "override-view-default-dep"}]} + + @pytest.fixture(scope="class") + def project_config_update(self): + return { + "flags": { + "deprecate_package_materialization_builtin_override": True, + }, + } + + def test_default_dependency_deprecated( + self, project, override_view_default_dep, set_up_deprecations + ): + run_dbt(["deps"]) + # this should pass because the override is buggy and unused + run_dbt(["run"]) + + # overriding a built-in materialization from package is deprecated + assert deprecations.active_deprecations == set() + + +class TestOverrideDefaultDependencyLegacy: + @pytest.fixture(scope="class") + def packages(self): + return {"packages": [{"local": "override-view-default-dep"}]} + + @pytest.fixture(scope="class") + def project_config_update(self): + return { + "flags": { + "deprecate_package_materialization_builtin_override": False, + }, + } + + def test_default_dependency(self, project, override_view_default_dep, set_up_deprecations): + run_dbt(["deps"]) + # this should error because the override is buggy + run_dbt(["run"], expect_pass=False) + + # overriding a built-in materialization from package is deprecated + assert deprecations.active_deprecations == {"package-materialization-override"} + + root_view_override_macro = """ {% materialization view, default %} {{ return(view_default_override.materialization_view_default()) }} From b59bfa15921431868993a0a3a310efab43898173 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Mon, 22 Apr 2024 17:37:08 -0400 Subject: [PATCH 4/8] changelog entry --- .changes/unreleased/Features-20240422-173703.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Features-20240422-173703.yaml diff --git a/.changes/unreleased/Features-20240422-173703.yaml b/.changes/unreleased/Features-20240422-173703.yaml new file mode 100644 index 00000000000..02019b2b99c --- /dev/null +++ b/.changes/unreleased/Features-20240422-173703.yaml @@ -0,0 +1,6 @@ +kind: Features +body: Add flags.deprecate_package_materialization_builtin_override +time: 2024-04-22T17:37:03.892268-04:00 +custom: + Author: michelleark + Issue: "10007" From c9bc67935c0252eabe50e5d01622cad069138ea7 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Tue, 23 Apr 2024 13:00:37 -0400 Subject: [PATCH 5/8] fix test_find_materialization_by_name --- tests/unit/test_manifest.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/unit/test_manifest.py b/tests/unit/test_manifest.py index ea443d1147f..602d2d9321b 100644 --- a/tests/unit/test_manifest.py +++ b/tests/unit/test_manifest.py @@ -1392,6 +1392,14 @@ def id_mat(arg): ids=id_mat, ) def test_find_materialization_by_name(macros, adapter_type, expected): + set_from_args( + Namespace( + SEND_ANONYMOUS_USAGE_STATS=False, + DEPRECATE_PACKAGE_MATERIALIZATION_BUILTIN_OVERRIDE=False, + ), + None, + ) + manifest = make_manifest(macros=macros) result = manifest.find_materialization_macro_by_name( project_name="root", From 5544b7da3eec7f0615b73639eb50cd4803dc4125 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Tue, 23 Apr 2024 13:02:47 -0400 Subject: [PATCH 6/8] update changelog --- .changes/unreleased/Features-20240422-173703.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changes/unreleased/Features-20240422-173703.yaml b/.changes/unreleased/Features-20240422-173703.yaml index 02019b2b99c..3ad5ad6ebf5 100644 --- a/.changes/unreleased/Features-20240422-173703.yaml +++ b/.changes/unreleased/Features-20240422-173703.yaml @@ -1,5 +1,5 @@ kind: Features -body: Add flags.deprecate_package_materialization_builtin_override +body: Add deprecate_package_materialization_builtin_override to dbt_project.yml flags, which can be used to opt-out of overriding built-in materializations from packages time: 2024-04-22T17:37:03.892268-04:00 custom: Author: michelleark From 516fb5945365c992aca5ad6c0a221413ffd61d67 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Tue, 23 Apr 2024 14:24:40 -0400 Subject: [PATCH 7/8] add test_find_materialization_by_name_legacy --- tests/unit/test_manifest.py | 171 +++++++++++++++++++++++++++++++++++- 1 file changed, 169 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_manifest.py b/tests/unit/test_manifest.py index 602d2d9321b..1ed165bb95f 100644 --- a/tests/unit/test_manifest.py +++ b/tests/unit/test_manifest.py @@ -1240,7 +1240,7 @@ def test_find_generate_macros_by_name(macros, expectations): FindMaterializationSpec = namedtuple("FindMaterializationSpec", "macros,adapter_type,expected") -def _materialization_parameter_sets(): +def _materialization_parameter_sets_legacy(): # inject the plugins used for materialization parameter tests FooPlugin = AdapterPlugin( adapter=mock.MagicMock(), @@ -1386,6 +1386,173 @@ def id_mat(arg): return "_".join(arg) +@pytest.mark.parametrize( + "macros,adapter_type,expected", + _materialization_parameter_sets_legacy(), + ids=id_mat, +) +def test_find_materialization_by_name_legacy(macros, adapter_type, expected): + set_from_args( + Namespace( + SEND_ANONYMOUS_USAGE_STATS=False, + DEPRECATE_PACKAGE_MATERIALIZATION_BUILTIN_OVERRIDE=False, + ), + None, + ) + + manifest = make_manifest(macros=macros) + result = manifest.find_materialization_macro_by_name( + project_name="root", + materialization_name="my_materialization", + adapter_type=adapter_type, + ) + if expected is None: + assert result is expected + else: + expected_package, expected_adapter_type = expected + assert result.adapter_type == expected_adapter_type + assert result.package_name == expected_package + + +def _materialization_parameter_sets(): + # inject the plugins used for materialization parameter tests + FooPlugin = AdapterPlugin( + adapter=mock.MagicMock(), + credentials=mock.MagicMock(), + include_path="/path/to/root/plugin", + project_name="foo", + ) + FooPlugin.adapter.type.return_value = "foo" + inject_plugin(FooPlugin) + + BarPlugin = AdapterPlugin( + adapter=mock.MagicMock(), + credentials=mock.MagicMock(), + include_path="/path/to/root/plugin", + dependencies=["foo"], + project_name="bar", + ) + BarPlugin.adapter.type.return_value = "bar" + inject_plugin(BarPlugin) + + sets = [ + FindMaterializationSpec(macros=[], adapter_type="foo", expected=None), + ] + + # default only, each project + sets.extend( + FindMaterializationSpec( + macros=[MockMaterialization(project, adapter_type=None)], + adapter_type="foo", + expected=(project, "default"), + ) + for project in ["root", "dep", "dbt"] + ) + + # other type only, each project + sets.extend( + FindMaterializationSpec( + macros=[MockMaterialization(project, adapter_type="bar")], + adapter_type="foo", + expected=None, + ) + for project in ["root", "dep", "dbt"] + ) + + # matching type only, each project + sets.extend( + FindMaterializationSpec( + macros=[MockMaterialization(project, adapter_type="foo")], + adapter_type="foo", + expected=(project, "foo"), + ) + for project in ["root", "dep", "dbt"] + ) + + sets.extend( + [ + # matching type and default everywhere + FindMaterializationSpec( + macros=[ + MockMaterialization(project, adapter_type=atype) + for (project, atype) in product(["root", "dep", "dbt"], ["foo", None]) + ], + adapter_type="foo", + expected=("root", "foo"), + ), + # default in core, override is in dep, and root has unrelated override + # should find the dbt default because default materializations cannot be overwritten by packages. + FindMaterializationSpec( + macros=[ + MockMaterialization("root", adapter_type="bar"), + MockMaterialization("dep", adapter_type="foo"), + MockMaterialization("dbt", adapter_type=None), + ], + adapter_type="foo", + expected=("dbt", "default"), + ), + # default in core, unrelated override is in dep, and root has an override + # should find the root override. + FindMaterializationSpec( + macros=[ + MockMaterialization("root", adapter_type="foo"), + MockMaterialization("dep", adapter_type="bar"), + MockMaterialization("dbt", adapter_type=None), + ], + adapter_type="foo", + expected=("root", "foo"), + ), + # default in core, override is in dep, and root has an override too. + # should find the root override. + FindMaterializationSpec( + macros=[ + MockMaterialization("root", adapter_type="foo"), + MockMaterialization("dep", adapter_type="foo"), + MockMaterialization("dbt", adapter_type=None), + ], + adapter_type="foo", + expected=("root", "foo"), + ), + # core has default + adapter, dep has adapter, root has default + # should find the default adapter implementation, because it's the most specific + # and default materializations cannot be overwritten by packages + FindMaterializationSpec( + macros=[ + MockMaterialization("root", adapter_type=None), + MockMaterialization("dep", adapter_type="foo"), + MockMaterialization("dbt", adapter_type=None), + MockMaterialization("dbt", adapter_type="foo"), + ], + adapter_type="foo", + expected=("dbt", "foo"), + ), + ] + ) + + # inherit from parent adapter + sets.extend( + FindMaterializationSpec( + macros=[MockMaterialization(project, adapter_type="foo")], + adapter_type="bar", + expected=(project, "foo"), + ) + for project in ["root", "dep", "dbt"] + ) + sets.extend( + FindMaterializationSpec( + macros=[ + MockMaterialization(project, adapter_type="foo"), + MockMaterialization(project, adapter_type="bar"), + ], + adapter_type="bar", + expected=(project, "bar"), + ) + for project in ["root", "dep", "dbt"] + ) + + return sets + + @pytest.mark.parametrize( "macros,adapter_type,expected", _materialization_parameter_sets(), @@ -1395,7 +1562,7 @@ def test_find_materialization_by_name(macros, adapter_type, expected): set_from_args( Namespace( SEND_ANONYMOUS_USAGE_STATS=False, - DEPRECATE_PACKAGE_MATERIALIZATION_BUILTIN_OVERRIDE=False, + DEPRECATE_PACKAGE_MATERIALIZATION_BUILTIN_OVERRIDE=True, ), None, ) From 3e3895020246afd4e4375f9b7dac9476de47ca26 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Tue, 23 Apr 2024 14:30:50 -0400 Subject: [PATCH 8/8] rename to require_explicit_package_overrides_for_builtin_materializations --- .changes/unreleased/Features-20240422-173703.yaml | 2 +- core/dbt/contracts/graph/manifest.py | 5 ++++- core/dbt/contracts/project.py | 4 ++-- core/dbt/events/types.py | 2 +- .../materializations/test_custom_materialization.py | 8 ++++---- tests/unit/test_manifest.py | 4 ++-- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.changes/unreleased/Features-20240422-173703.yaml b/.changes/unreleased/Features-20240422-173703.yaml index 3ad5ad6ebf5..3c957af40c1 100644 --- a/.changes/unreleased/Features-20240422-173703.yaml +++ b/.changes/unreleased/Features-20240422-173703.yaml @@ -1,5 +1,5 @@ kind: Features -body: Add deprecate_package_materialization_builtin_override to dbt_project.yml flags, which can be used to opt-out of overriding built-in materializations from packages +body: Add require_explicit_package_overrides_for_builtin_materializations to dbt_project.yml flags, which can be used to opt-out of overriding built-in materializations from packages time: 2024-04-22T17:37:03.892268-04:00 custom: Author: michelleark diff --git a/core/dbt/contracts/graph/manifest.py b/core/dbt/contracts/graph/manifest.py index 20decafae15..b7b8142d72e 100644 --- a/core/dbt/contracts/graph/manifest.py +++ b/core/dbt/contracts/graph/manifest.py @@ -961,7 +961,10 @@ def find_materialization_macro_by_name( and core_candidates ): # preserve legacy behaviour - allow materialization override - if get_flags().deprecate_package_materialization_builtin_override is False: + if ( + get_flags().require_explicit_package_overrides_for_builtin_materializations + is False + ): deprecations.warn( "package-materialization-override", package_name=materialization_candidate.macro.package_name, diff --git a/core/dbt/contracts/project.py b/core/dbt/contracts/project.py index 34fb8c50b97..a74b883005d 100644 --- a/core/dbt/contracts/project.py +++ b/core/dbt/contracts/project.py @@ -299,7 +299,6 @@ class ProjectFlags(ExtensibleDbtClassMixin): allow_spaces_in_model_names: Optional[bool] = True cache_selected_only: Optional[bool] = None debug: Optional[bool] = None - deprecate_package_materialization_builtin_override: bool = False fail_fast: Optional[bool] = None indirect_selection: Optional[str] = None log_format: Optional[str] = None @@ -309,6 +308,7 @@ class ProjectFlags(ExtensibleDbtClassMixin): partial_parse: Optional[bool] = None populate_cache: Optional[bool] = None printer_width: Optional[int] = None + require_explicit_package_overrides_for_builtin_materializations: bool = False send_anonymous_usage_stats: bool = DEFAULT_SEND_ANONYMOUS_USAGE_STATS source_freshness_run_project_hooks: bool = False static_parser: Optional[bool] = None @@ -325,7 +325,7 @@ def project_only_flags(self) -> Dict[str, Any]: return { "source_freshness_run_project_hooks": self.source_freshness_run_project_hooks, "allow_spaces_in_model_names": self.allow_spaces_in_model_names, - "deprecate_package_materialization_builtin_override": self.deprecate_package_materialization_builtin_override, + "require_explicit_package_overrides_for_builtin_materializations": self.require_explicit_package_overrides_for_builtin_materializations, } diff --git a/core/dbt/events/types.py b/core/dbt/events/types.py index 4990b7bfaa6..b618ec6ba22 100644 --- a/core/dbt/events/types.py +++ b/core/dbt/events/types.py @@ -455,7 +455,7 @@ def code(self) -> str: return "D016" def message(self) -> str: - description = f"Installed package '{self.package_name}' is overriding the built-in materialization '{self.materialization_name}'. Overrides of built-in materializations from installed packages will be deprecated in future versions of dbt. Please refer to https://docs.getdbt.com/reference/global-configs/legacy-behaviors#deprecate_package_materialization_builtin_override for detailed documentation and suggested workarounds." + description = f"Installed package '{self.package_name}' is overriding the built-in materialization '{self.materialization_name}'. Overrides of built-in materializations from installed packages will be deprecated in future versions of dbt. Please refer to https://docs.getdbt.com/reference/global-configs/legacy-behaviors#require_explicit_package_overrides_for_builtin_materializations for detailed documentation and suggested workarounds." return line_wrap_message(warning_tag(description)) diff --git a/tests/functional/materializations/test_custom_materialization.py b/tests/functional/materializations/test_custom_materialization.py index b2410ed83ed..2c3ec4e74c2 100644 --- a/tests/functional/materializations/test_custom_materialization.py +++ b/tests/functional/materializations/test_custom_materialization.py @@ -55,7 +55,7 @@ def packages(self): def project_config_update(self): return { "flags": { - "deprecate_package_materialization_builtin_override": True, + "require_explicit_package_overrides_for_builtin_materializations": True, }, } @@ -81,7 +81,7 @@ def packages(self): def project_config_update(self): return { "flags": { - "deprecate_package_materialization_builtin_override": False, + "require_explicit_package_overrides_for_builtin_materializations": False, }, } @@ -117,7 +117,7 @@ def packages(self): def project_config_update(self): return { "flags": { - "deprecate_package_materialization_builtin_override": True, + "require_explicit_package_overrides_for_builtin_materializations": True, }, } @@ -141,7 +141,7 @@ def packages(self): def project_config_update(self): return { "flags": { - "deprecate_package_materialization_builtin_override": False, + "require_explicit_package_overrides_for_builtin_materializations": False, }, } diff --git a/tests/unit/test_manifest.py b/tests/unit/test_manifest.py index 1ed165bb95f..e335a09295a 100644 --- a/tests/unit/test_manifest.py +++ b/tests/unit/test_manifest.py @@ -1395,7 +1395,7 @@ def test_find_materialization_by_name_legacy(macros, adapter_type, expected): set_from_args( Namespace( SEND_ANONYMOUS_USAGE_STATS=False, - DEPRECATE_PACKAGE_MATERIALIZATION_BUILTIN_OVERRIDE=False, + REQUIRE_EXPLICIT_PACKAGE_OVERRIDES_FOR_BUILTIN_MATERIALIZATIONS=False, ), None, ) @@ -1562,7 +1562,7 @@ def test_find_materialization_by_name(macros, adapter_type, expected): set_from_args( Namespace( SEND_ANONYMOUS_USAGE_STATS=False, - DEPRECATE_PACKAGE_MATERIALIZATION_BUILTIN_OVERRIDE=True, + REQUIRE_EXPLICIT_PACKAGE_OVERRIDES_FOR_BUILTIN_MATERIALIZATIONS=True, ), None, )