forked from dbt-labs/dbt-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray_construct.sql
More file actions
24 lines (20 loc) · 815 Bytes
/
array_construct.sql
File metadata and controls
24 lines (20 loc) · 815 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
{% macro array_construct(inputs = [], data_type = api.Column.translate_type('integer')) -%}
{{ return(adapter.dispatch('array_construct', 'dbt_utils')(inputs, data_type)) }}
{%- endmacro %}
{# all inputs must be the same data type to match postgres functionality #}
{% macro default__array_construct(inputs, data_type) -%}
{% if inputs|length > 0 %}
array[ {{ inputs|join(' , ') }} ]
{% else %}
array[]::{{data_type}}[]
{% endif %}
{%- endmacro %}
{% macro snowflake__array_construct(inputs, data_type) -%}
array_construct( {{ inputs|join(' , ') }} )
{%- endmacro %}
{% macro redshift__array_construct(inputs, data_type) -%}
array( {{ inputs|join(' , ') }} )
{%- endmacro %}
{% macro bigquery__array_construct(inputs, data_type) -%}
[ {{ inputs|join(' , ') }} ]
{%- endmacro %}