-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update README.md * Mutually excl range examples in disclosure triangle * Fix union_relations error when no include/exclude provided * Fix union_relations error when no include/exclude provided (#509) * Update CHANGELOG.md * Add to_condition to relationships where * very minor nit - update "an new" to "a new" (#519) * add quoting to split_part (#528) * add quoting to split_part * update docs for split_part * typo * corrected readme syntax * revert and update to just documentation * add new line * Update README.md * Update README.md * Update README.md Co-authored-by: Joel Labes <joel.labes@dbtlabs.com> * add macro to get columns (#516) * add macro to get columns * star macro should use get_columns * add adapter. * swap adapter for dbt_utils Co-authored-by: Joel Labes <joel.labes@dbtlabs.com> * update documentation * add output_lower arg * update name to get_filtered_columns_in_relation from get_columns * add tests * forgot args * too much whitespace removal ----------- Actual: ----------- --->"field_3"as "test_field_3"<--- ----------- Expected: ----------- --->"field_3" as "test_field_3"<--- * didnt mean to move a file that i did not create. moving things back. * remove lowercase logic * limit_zero Co-authored-by: Joel Labes <joel.labes@dbtlabs.com> * Add listagg macro and integration test * remove type in listagg macro * updated integration test * Add redshift to listagg macro * remove redshift listagg * explicitly named group by column * updated default values * Updated example to use correct double vs. single quotes * whitespace control * Added redshift specific macro * Remove documentation * Update integration test so less likely to accidentally work Co-authored-by: Joel Labes <joel.labes@dbtlabs.com> * default everything but measure to none * added limit functionality for other dbs * syntax bug for postgres * update redshift macro * fixed block def control * Fixed bug in redshift * Bug fix redshift * remove unused group_by arg * Added additional test without order by col * updated to regex replace * typo * added more integration_tests * attempt to make redshift less complicated * typo * update redshift * replace to substr * More explicit versions with added complexity * handle special characters Co-authored-by: Joel Labes <joel.labes@dbtlabs.com> Co-authored-by: Jamie Rosenberg <james.rosenberg@canva.com> Co-authored-by: Pat Kearns <pat.kearns@fishtownanalytics.com>
- Loading branch information
1 parent
31577cb
commit 1a517d2
Showing
15 changed files
with
358 additions
and
20 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
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,10 @@ | ||
group_col,string_text,order_col | ||
1,a,1 | ||
1,b,2 | ||
1,c,3 | ||
2,a,2 | ||
2,1,1 | ||
2,p,3 | ||
3,g,1 | ||
3,g,2 | ||
3,g,3 |
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,10 @@ | ||
group_col,expected,version | ||
1,"a_|_b_|_c",bottom_ordered | ||
2,"1_|_a_|_p",bottom_ordered | ||
3,"g_|_g_|_g",bottom_ordered | ||
1,"a_|_b",bottom_ordered_limited | ||
2,"1_|_a",bottom_ordered_limited | ||
3,"g_|_g",bottom_ordered_limited | ||
3,"g, g, g",comma_whitespace_unordered | ||
3,"g",distinct_comma | ||
3,"g,g,g",no_params |
4 changes: 4 additions & 0 deletions
4
integration_tests/data/sql/data_filtered_columns_in_relation.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,4 @@ | ||
field_1,field_2,field_3 | ||
a,b,c | ||
d,e,f | ||
g,h,i |
2 changes: 2 additions & 0 deletions
2
integration_tests/data/sql/data_filtered_columns_in_relation_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,2 @@ | ||
field_2,field_3 | ||
h,i |
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,32 @@ | ||
{% macro assert_equal_values(actual_object, expected_object) %} | ||
{% if not execute %} | ||
|
||
{# pass #} | ||
|
||
{% elif actual_object != expected_object %} | ||
|
||
{% set msg %} | ||
Expected did not match actual | ||
|
||
----------- | ||
Actual: | ||
----------- | ||
--->{{ actual_object }}<--- | ||
|
||
----------- | ||
Expected: | ||
----------- | ||
--->{{ expected_object }}<--- | ||
|
||
{% endset %} | ||
|
||
{{ log(msg, info=True) }} | ||
|
||
select 'fail' | ||
|
||
{% else %} | ||
|
||
select 'ok' {{ limit_zero() }} | ||
|
||
{% endif %} | ||
{% endmacro %} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
with data as ( | ||
|
||
select * from {{ ref('data_listagg') }} | ||
|
||
), | ||
|
||
data_output as ( | ||
|
||
select * from {{ ref('data_listagg_output') }} | ||
|
||
), | ||
|
||
calculate as ( | ||
|
||
select | ||
group_col, | ||
{{ dbt_utils.listagg('string_text', "'_|_'", "order by order_col") }} as actual, | ||
'bottom_ordered' as version | ||
from data | ||
group by group_col | ||
|
||
union all | ||
|
||
select | ||
group_col, | ||
{{ dbt_utils.listagg('string_text', "'_|_'", "order by order_col", 2) }} as actual, | ||
'bottom_ordered_limited' as version | ||
from data | ||
group by group_col | ||
|
||
union all | ||
|
||
select | ||
group_col, | ||
{{ dbt_utils.listagg('string_text', "', '") }} as actual, | ||
'comma_whitespace_unordered' as version | ||
from data | ||
where group_col = 3 | ||
group by group_col | ||
|
||
union all | ||
|
||
select | ||
group_col, | ||
{{ dbt_utils.listagg('DISTINCT string_text', "','") }} as actual, | ||
'distinct_comma' as version | ||
from data | ||
where group_col = 3 | ||
group by group_col | ||
|
||
union all | ||
|
||
select | ||
group_col, | ||
{{ dbt_utils.listagg('string_text') }} as actual, | ||
'no_params' as version | ||
from data | ||
where group_col = 3 | ||
group by group_col | ||
|
||
) | ||
|
||
select | ||
calculate.actual, | ||
data_output.expected | ||
from calculate | ||
left join data_output | ||
on calculate.group_col = data_output.group_col | ||
and calculate.version = data_output.version |
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
16 changes: 16 additions & 0 deletions
16
integration_tests/models/sql/test_get_filtered_columns_in_relation.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,16 @@ | ||
{% set exclude_field = 'field_1' %} | ||
{% set column_names = dbt_utils.get_filtered_columns_in_relation(from= ref('data_filtered_columns_in_relation'), except=[exclude_field]) %} | ||
|
||
with data as ( | ||
|
||
select | ||
|
||
{% for column_name in column_names %} | ||
max({{ column_name }}) as {{ column_name }} {% if not loop.last %},{% endif %} | ||
{% endfor %} | ||
|
||
from {{ ref('data_filtered_columns_in_relation') }} | ||
|
||
) | ||
|
||
select * from data |
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,13 @@ | ||
{% set exclude_field = 'FIELD_3' %} | ||
|
||
|
||
with data as ( | ||
|
||
select | ||
{{ dbt_utils.star(from=ref('data_star'), except=[exclude_field]) }} | ||
|
||
from {{ ref('data_star') }} | ||
|
||
) | ||
|
||
select * from data |
Oops, something went wrong.