-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add flags.deprecate_package_materialization_builtin_override #9956
Changes from all commits
99998a5
97334f7
02e93d2
3552c2a
b59bfa1
7173b6e
c9bc679
5544b7d
516fb59
3e38950
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Features | ||
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 | ||
Issue: "10007" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -571,11 +571,25 @@ | |
|
||
|
||
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() | ||
|
@@ -946,11 +960,20 @@ | |
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().require_explicit_package_overrides_for_builtin_materializations | ||
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] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. was not able to do this lower-level using the |
||
) | ||
|
||
return materialization_candidate.macro if materialization_candidate else None | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to have been broken all along, but was never reached in testing