Skip to content

Commit d4bfa65

Browse files
committed
Fix column transformations for Snowflake
1 parent bb5fbd1 commit d4bfa65

File tree

5 files changed

+44
-7
lines changed

5 files changed

+44
-7
lines changed

integration-tests/dbt_project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ vars:
2424
unit_tests_config:
2525
column_transformations:
2626
model_for_column_transformations:
27-
b: upper(b)
27+
column_a: round(##column##, 5)
2828
model_references_model_with_structs:
2929
a: to_json_string(##column##)
3030
verbose: false
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
select a / 3 as a, b from {{ dbt_unit_testing.ref ('model_a') }}
1+
select a / 3 as column_a, b as column_b from {{ dbt_unit_testing.ref ('model_a') }}
Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{{
22
config(
3-
tags=['unit-test', 'bigquery', 'snowflake', 'postgres']
3+
tags=['unit-test', 'bigquery', 'postgres']
44
)
55
}}
66

77
{% set column_transformations = {
8-
"a": "round(##column##, 4)"
8+
"column_a": "round(##column##, 4)",
9+
"column_b": "upper(##column##)"
910
}
1011
%}
1112

@@ -14,6 +15,22 @@
1415
select 10.0 as a, 'lower' as b
1516
{% endcall %}
1617
{% call dbt_unit_testing.expect() %}
17-
select 3.3333 as a, 'LOWER' as b
18+
select 3.3333 as column_a, 'LOWER' as column_b
19+
{% endcall %}
20+
{% endcall %}
21+
22+
UNION ALL
23+
24+
{% set column_transformations = {
25+
"column_b": "upper(##column##)"
26+
}
27+
%}
28+
29+
{% call dbt_unit_testing.test('model_for_column_transformations', 'should merge config from dbt_project', options={"column_transformations": column_transformations}) %}
30+
{% call dbt_unit_testing.mock_ref ('model_a') %}
31+
select 10.0 as a, 'lower' as b
32+
{% endcall %}
33+
{% call dbt_unit_testing.expect() %}
34+
select 3.33333 as column_a, 'LOWER' as column_b
1835
{% endcall %}
1936
{% endcall %}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{
2+
config(
3+
tags=['unit-test', 'snowflake']
4+
)
5+
}}
6+
7+
{% set column_transformations = {
8+
"COLUMN_A": "round(##column##, 4)",
9+
"COLUMN_B": "upper(##column##)"
10+
}
11+
%}
12+
13+
{% call dbt_unit_testing.test('model_for_column_transformations', options={"column_transformations": column_transformations}) %}
14+
{% call dbt_unit_testing.mock_ref ('model_a') %}
15+
select 10.0 as a, 'lower' as b
16+
{% endcall %}
17+
{% call dbt_unit_testing.expect() %}
18+
select 3.3333 as COLUMN_A, 'LOWER' as column_b
19+
{% endcall %}
20+
{% endcall %}

run-tests-helper.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ function run_tests() {
77
if [ "$PROFILE" == "postgres" ]; then
88
VERSIONS="1.3.4 1.4.6 1.5.4 1.7.4"
99
elif [ "$PROFILE" == "bigquery" ]; then
10-
VERSIONS="1.3.2"
10+
VERSIONS="1.7.2"
1111
elif [ "$PROFILE" == "snowflake" ]; then
12-
VERSIONS="1.3.1"
12+
VERSIONS="1.7.1"
1313
else
1414
echo "Invalid profile name: $PROFILE"
1515
exit 1

0 commit comments

Comments
 (0)