Skip to content

Commit

Permalink
Fix #8031: Call materialization macro from adapter dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
aranke committed Aug 10, 2023
1 parent e69d4e7 commit 3d2dd84
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20230810-183216.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Call materialization macro from adapter dispatch
time: 2023-08-10T18:32:16.226142+01:00
custom:
Author: aranke
Issue: "8031"
6 changes: 5 additions & 1 deletion core/dbt/context/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ def dispatch(

for package_name in search_packages:
for prefix in self._get_adapter_macro_prefixes():
search_name = f"{prefix}__{macro_name}"
search_name = (
macro_name
if macro_name.startswith("materialization_")
else f"{prefix}__{macro_name}"
)
try:
# this uses the namespace from the context
macro = self._namespace.get_from_package(package_name, search_name)
Expand Down
3 changes: 1 addition & 2 deletions core/dbt/task/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from typing import AbstractSet, Any, List, Iterable, Set

from dbt.adapters.base import BaseRelation
from dbt.clients.jinja import MacroGenerator
from dbt.context.providers import generate_runtime_model_context
from dbt.contracts.results import RunStatus, RunResult
from dbt.dataclass_schema import dbtClassMixin
Expand Down Expand Up @@ -80,7 +79,7 @@ def execute(self, model, manifest):

hook_ctx = self.adapter.pre_model_hook(context_config)
try:
result = MacroGenerator(materialization_macro, context)()
result = context["adapter"].dispatch(materialization_macro.name)()
finally:
self.adapter.post_model_hook(context_config, hook_ctx)

Expand Down

0 comments on commit 3d2dd84

Please sign in to comment.