From 1bc0f2e0758e33ddcf48fcd595d48634c5ec827a Mon Sep 17 00:00:00 2001 From: "ajay.abrol2" Date: Wed, 20 Dec 2023 02:37:17 -0500 Subject: [PATCH] Added files to utils --- dbt/include/vertica/macros/utils/array_concat.sql | 2 +- .../vertica/macros/utils/array_construct.sql | 4 ++-- setup.py | 1 + .../adapter/utils/test_array_construct.py | 15 +++++++++++---- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/dbt/include/vertica/macros/utils/array_concat.sql b/dbt/include/vertica/macros/utils/array_concat.sql index 7fe9d74..d0f0035 100644 --- a/dbt/include/vertica/macros/utils/array_concat.sql +++ b/dbt/include/vertica/macros/utils/array_concat.sql @@ -1,3 +1,3 @@ {% macro array_concat(array_1, array_2) -%} - array_concat({{ array_1 }}, {{ array_2 }}) + array_cat({{ array_1 }}, {{ array_2 }}) {%- endmacro %} \ No newline at end of file diff --git a/dbt/include/vertica/macros/utils/array_construct.sql b/dbt/include/vertica/macros/utils/array_construct.sql index c10d9fa..4f2c968 100644 --- a/dbt/include/vertica/macros/utils/array_construct.sql +++ b/dbt/include/vertica/macros/utils/array_construct.sql @@ -1,7 +1,7 @@ {% macro array_construct(inputs, data_type) -%} {% if inputs|length > 0 %} - [ {{ inputs|join(' , ') }} ] + ARRAY[ {{ inputs|join(' , ') }} ] {% else %} - ARRAY<{{data_type}}>[] + ARRAY[{{data_type}}] {% endif %} {%- endmacro %} \ No newline at end of file diff --git a/setup.py b/setup.py index 0143d67..304c6c6 100644 --- a/setup.py +++ b/setup.py @@ -107,6 +107,7 @@ def _get_dbt_core_version(): 'include/vertica/macros/materializations/models/view/*.sql', 'include/vertica/macros/materializations/seeds/*.sql', 'include/vertica/macros/materializations/snapshots/*.sql', + 'include/vertica/macros/utils/*.sql', ] }, install_requires=[ diff --git a/tests/functional/adapter/utils/test_array_construct.py b/tests/functional/adapter/utils/test_array_construct.py index 72bc0e1..20e84b6 100644 --- a/tests/functional/adapter/utils/test_array_construct.py +++ b/tests/functional/adapter/utils/test_array_construct.py @@ -15,12 +15,19 @@ import pytest from dbt.tests.adapter.utils.base_array_utils import BaseArrayUtils -from dbt.tests.adapter.utils.fixture_array_construct import ( - models__array_construct_actual_sql, - models__array_construct_expected_sql, -) +models__array_construct_expected_sql = """ +select 1 as id, {{ array_construct([1,2,3]) }} as array_col union all +select 2 as id, {{ array_construct([0]) }} as array_col +""" + + +models__array_construct_actual_sql = """ +select 1 as id, {{ array_construct([1,2,3]) }} as array_col union all +select 2 as id, {{ array_construct([0]) }} as array_col +""" + class BaseArrayConstruct(BaseArrayUtils): @pytest.fixture(scope="class") def models(self):