Skip to content

Commit

Permalink
Helper macro to a reuse a fundamental materialization type (like tabl…
Browse files Browse the repository at this point in the history
…e, view, or materialized_view)
  • Loading branch information
dbeatty10 committed Sep 29, 2023
1 parent 468c85c commit 6a83646
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% macro get_materialization_macro(materialization_type) -%}
-- Reuse a fundamental materialization type (like table, view, or materialized_view)
-- TODO: support actual dispatch for materialization macros
-- See related tracking ticket: https://github.com/dbt-labs/dbt-core/issues/7799
{% set base_search_name = "materialization_" ~ materialization_type ~ "_" %}
{% set search_name = base_search_name ~ adapter.type() %}

{% if not search_name in context %}
{% set search_name = base_search_name ~ "default" %}
{% endif %}
{% set materialization_macro = context[search_name] %}
{% do return(materialization_macro) %}
{%- endmacro %}

0 comments on commit 6a83646

Please sign in to comment.