-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add optional where clause to get_column_values (#583)
* Add optional where clause to get_column_values * Add new argument for get_column_values to README * Add an entry to CHANGELOG.md * Reorder args * Fix typo0 * Fix typo * Add integration test for get_column_values where argument * Update where arg test to use data_get_column_values_where_expected * Update CHANGELOG.md Co-authored-by: Doug Beatty <44704949+dbeatty10@users.noreply.github.com> * Reorder changelog entry Co-authored-by: Doug Beatty <44704949+dbeatty10@users.noreply.github.com>
- Loading branch information
Showing
7 changed files
with
40 additions
and
3 deletions.
There are no files selected for viewing
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
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
12 changes: 12 additions & 0 deletions
12
integration_tests/data/sql/data_get_column_values_where.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,condition | ||
a,left | ||
b,right | ||
c,left | ||
d,right | ||
e,left | ||
f,right | ||
g,left | ||
g,right | ||
g,left | ||
g,right | ||
g,left |
5 changes: 5 additions & 0 deletions
5
integration_tests/data/sql/data_get_column_values_where_expected.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,5 @@ | ||
field | ||
a | ||
c | ||
e | ||
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
6 changes: 6 additions & 0 deletions
6
integration_tests/models/sql/test_get_column_values_where.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,6 @@ | ||
{% set column_values = dbt_utils.get_column_values(ref('data_get_column_values_where'), 'field', where="condition = 'left'") %} | ||
|
||
-- Create a relation using the values | ||
{% for val in column_values -%} | ||
select {{ dbt_utils.string_literal(val) }} as field {% if not loop.last %}union all{% endif %} | ||
{% endfor %} |
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