Skip to content

Commit

Permalink
rename to require_explicit_package_overrides_for_builtin_materializat…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
MichelleArk committed Apr 23, 2024
1 parent 516fb59 commit 3e38950
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .changes/unreleased/Features-20240422-173703.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 4 additions & 1 deletion core/dbt/contracts/graph/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions core/dbt/contracts/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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,
}


Expand Down
2 changes: 1 addition & 1 deletion core/dbt/events/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}

Expand All @@ -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,
},
}

Expand Down Expand Up @@ -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,
},
}

Expand All @@ -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,
},
}

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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,
)
Expand Down

0 comments on commit 3e38950

Please sign in to comment.