From 6a83646368e289f921a71f11953fe3eb5dabe0eb Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Fri, 29 Sep 2023 08:06:58 -0600 Subject: [PATCH] Helper macro to a reuse a fundamental materialization type (like table, view, or materialized_view) --- .../macros/materializations/helpers.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 core/dbt/include/global_project/macros/materializations/helpers.sql diff --git a/core/dbt/include/global_project/macros/materializations/helpers.sql b/core/dbt/include/global_project/macros/materializations/helpers.sql new file mode 100644 index 00000000000..4b31e8dd44c --- /dev/null +++ b/core/dbt/include/global_project/macros/materializations/helpers.sql @@ -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 %}