Skip to content

Commit

Permalink
Added files to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
ajay-abrol2 committed Dec 20, 2023
1 parent cdb8dce commit 1bc0f2e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dbt/include/vertica/macros/utils/array_concat.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{% macro array_concat(array_1, array_2) -%}
array_concat({{ array_1 }}, {{ array_2 }})
array_cat({{ array_1 }}, {{ array_2 }})
{%- endmacro %}
4 changes: 2 additions & 2 deletions dbt/include/vertica/macros/utils/array_construct.sql
Original file line number Diff line number Diff line change
@@ -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 %}
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand Down
15 changes: 11 additions & 4 deletions tests/functional/adapter/utils/test_array_construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 1bc0f2e

Please sign in to comment.