forked from dbt-labs/dbt-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Regression: Correctly handle missing relations in get_column_values (d…
…bt-labs#448) * Create integration test for a dropped relation * Update get_column_values.sql * Swap out adapter call for a good old fashioned drop table
- Loading branch information
Showing
4 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
integration_tests/data/sql/data_get_column_values_dropped.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
field | ||
a | ||
b | ||
c | ||
d | ||
e | ||
f | ||
g | ||
g | ||
g | ||
g | ||
g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
integration_tests/tests/sql/test_get_column_values_use_default.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
{% set column_values = dbt_utils.get_column_values(ref('data_get_column_values_dropped'), 'field', default=['y', 'z'], order_by="field") %} | ||
|
||
with expected as ( | ||
select { dbt_utils.safe_cast('y', dbt_utils.type_string()) }} as expected union all | ||
select { dbt_utils.safe_cast('z', dbt_utils.type_string()) }} as expected | ||
), | ||
|
||
actual as ( | ||
select | ||
{% for val in column_values %} | ||
{{ dbt_utils.safe_cast(val, dbt_utils.type_string()) }} as 'actual' | ||
{% if not loop.last %} | ||
union all | ||
{% endif %} | ||
{% endfor %} | ||
), | ||
|
||
failures as ( | ||
select * from actual | ||
except | ||
select * from expected | ||
) | ||
|
||
select * from failures |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters