Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array macros #182

Merged
merged 11 commits into from
Sep 26, 2022
7 changes: 7 additions & 0 deletions .changes/unreleased/Features-20220912-223245.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Features
body: Array macros
time: 2022-09-12T22:32:45.764146-06:00
custom:
Author: graciegoheen dbeatty10
Issue: "181"
PR: "182"
3 changes: 3 additions & 0 deletions dbt/include/redshift/macros/utils/array_append.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% macro redshift__array_append(array, new_element) -%}
{{ array_concat(array, array_construct([new_element])) }}
{%- endmacro %}
3 changes: 3 additions & 0 deletions dbt/include/redshift/macros/utils/array_concat.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% macro redshift__array_concat(array_1, array_2) -%}
array_concat({{ array_1 }}, {{ array_2 }})
{%- endmacro %}
3 changes: 3 additions & 0 deletions dbt/include/redshift/macros/utils/array_construct.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% macro redshift__array_construct(inputs, data_type) -%}
array( {{ inputs|join(' , ') }} )
{%- endmacro %}
17 changes: 16 additions & 1 deletion tests/functional/adapter/utils/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import pytest
from dbt.tests.adapter.utils.base_utils import BaseUtils

from dbt.tests.adapter.utils.test_array_append import BaseArrayAppend
from dbt.tests.adapter.utils.test_array_concat import BaseArrayConcat
from dbt.tests.adapter.utils.test_array_construct import BaseArrayConstruct
from dbt.tests.adapter.utils.test_any_value import BaseAnyValue
from dbt.tests.adapter.utils.test_bool_or import BaseBoolOr
from dbt.tests.adapter.utils.test_cast_bool_to_text import BaseCastBoolToText
Expand Down Expand Up @@ -28,6 +31,18 @@ class TestAnyValue(BaseAnyValue):
pass


class TestArrayAppend(BaseArrayAppend):
pass


class TestArrayConcat(BaseArrayConcat):
pass


class TestArrayConstruct(BaseArrayConstruct):
pass


class TestBoolOr(BaseBoolOr):
pass

Expand Down