-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcustom_schema_management.sql
53 lines (35 loc) · 1.48 KB
/
custom_schema_management.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{#
Renders a schema name given a custom schema name. If the custom
schema name is none, then the resulting schema is just the "schema"
value in the specified target. If a schema override is specified, then
the resulting schema is the default schema concatenated with the
custom schema.
This macro can be overriden in projects to define different semantics
for rendering a schema name.
Arguments:
custom_schema_name: The custom schema name specified for a model, or none
node: The node the schema is being generated for
#}
{% macro generate_schema_name(custom_schema_name, node) -%}
{{ mybi_dbt_core.generate_schema_name_for_env(custom_schema_name, node) }}
{%- endmacro %}
{#
Renders a schema name given a custom schema name. In production, this macro
will render out the overriden schema name for a model. Otherwise, the default
schema specified in the active target is used.
Arguments:
custom_schema_name: The custom schema name specified for a model, or none
node: The node the schema is being generated for
#}
{% macro generate_schema_name_for_env(custom_schema_name, node) -%}
{%- set default_schema = target.schema -%}
{%- if target.name == 'prod' and custom_schema_name is not none -%}
{{ custom_schema_name | trim }}
{%- else -%}
{{ default_schema }}
{%- endif -%}
{%- endmacro %}
-- handle schema for audit models
{% macro get_audit_schema() %}
{{ return('meta') }}
{% endmacro %}