-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstar.sql
More file actions
25 lines (21 loc) · 804 Bytes
/
star.sql
File metadata and controls
25 lines (21 loc) · 804 Bytes
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
{% macro star(relation, except) %}
{%- set selects = [] -%}
{%- set columns = adapter.get_columns_in_relation(relation) -%}
{# If the except parameter is defined, we will only select the columns that are not in the except list. #}
{% if except is defined %}
{%- for column in columns -%}
{%- if column.name not in except -%}
{%- set selects = selects.append('"' + relation.identifier + '"."' + column.name + '"') -%}
{%- endif -%}
{%- endfor -%}
{# Generate the select statements in a later step to not put a comma after the last select. #}
{% for select in selects %}
{{ select }}
{%- if not loop.last -%}
,
{%- endif -%}
{% endfor %}
{% else %}
"{{ relation.identifier }}".*
{% endif %}
{% endmacro %}