forked from dbt-msft/dbt-sqlserver-utils
-
Notifications
You must be signed in to change notification settings - Fork 1
/
star.sql
31 lines (22 loc) · 1.02 KB
/
star.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
{% macro star(from, relation_alias=False, except=[]) -%}
{{ return(adapter.dispatch('star', packages = dbt_utils._get_utils_namespaces())(from, relation_alias, except)) }}
{% endmacro %}
{% macro default__star(from, relation_alias=False, except=[]) -%}
{%- do dbt_utils._is_relation(from, 'star') -%}
{%- do dbt_utils._is_ephemeral(from, 'star') -%}
{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}
{%- if not execute -%}
{{ return('') }}
{% endif %}
{%- set include_cols = [] %}
{%- set cols = adapter.get_columns_in_relation(from) -%}
{%- for col in cols -%}
{%- if col.column not in except -%}
{% do include_cols.append(col.column) %}
{%- endif %}
{%- endfor %}
{%- for col in include_cols %}
{%- if relation_alias %}{{ relation_alias }}.{% else %}{%- endif -%}{{ adapter.quote(col)|trim }}
{%- if not loop.last %},{{ '\n ' }}{% endif %}
{%- endfor -%}
{%- endmacro %}