Skip to content

Commit

Permalink
Extract most of the logic from find_materialization_macro_by_name t…
Browse files Browse the repository at this point in the history
…o `find_materialization_macro_candidate_by_name`

This is necessary because in the following commit we're going to add a function to get
whether or not a manifest should be run using the new microbatch functionality. Getting
the MacroCandidate is necessary because we need to know the locality of the macro.
  • Loading branch information
QMalcolm committed Nov 5, 2024
1 parent 4d908ad commit 0349968
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions core/dbt/contracts/graph/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -994,9 +994,9 @@ def _materialization_candidates_for(
for m in self._find_macros_by_name(full_name, project_name)
)

def find_materialization_macro_by_name(
def find_materialization_macro_candidate_by_name(
self, project_name: str, materialization_name: str, adapter_type: str
) -> Optional[Macro]:
) -> Optional[MacroCandidate]:
candidates: CandidateList = CandidateList(
chain.from_iterable(
self._materialization_candidates_for(
Expand Down Expand Up @@ -1034,6 +1034,16 @@ def find_materialization_macro_by_name(
valid_localities=[Locality.Core, Locality.Root]
)

return materialization_candidate

def find_materialization_macro_by_name(
self, project_name: str, materialization_name: str, adapter_type: str
) -> Optional[Macro]:
materialization_candidate = self.find_materialization_macro_candidate_by_name(
project_name=project_name,
materialization_name=materialization_name,
adapter_type=adapter_type,
)
return materialization_candidate.macro if materialization_candidate else None

def get_resource_fqns(self) -> Mapping[str, PathSet]:
Expand Down

0 comments on commit 0349968

Please sign in to comment.