data-dwh-dbt-project/macros/generate_schema_name.sql
2024-05-22 11:42:42 +02:00

18 lines
538 B
SQL

/*
This macro is necessary to allow different models to automatically be generated
in schemas different than the default one for the target database.
To understand better, check:
- https://www.youtube.com/watch?v=AvrVQr5FHwk
- https://docs.getdbt.com/docs/build/custom-schemas
*/
{% macro generate_schema_name(custom_schema_name, node) -%}
{%- set default_schema = target.schema -%}
{%- if custom_schema_name is none -%} {{ default_schema }}
{%- else -%} {{ custom_schema_name | trim }}
{%- endif -%}
{%- endmacro %}