-
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 link for fewer_rows_than schema test in docs (#465) * Update get_query_results_as_dict example to demonstrate accessing columnar results as dictionary values (#474) * Update get_qu ery_results_as_dict example to demonstrate accessing columnar results as dictionary values * Use slugify in example * Fix slugify example with dbt_utils. package prefix Co-authored-by: Elize Papineau <elize.papineau@dbtlabs.com> * Add note about not_null_where deprecation to Readme (#477) * Add note about not_null_where deprecation to Readme * Add docs to unique_where test * Update pull_request_template.md to reference `main` vs `master` (#496) * Correct coalesce -> concatenation typo (#495) * add any_value cross-db macro * Missing colon in test * Update CHANGELOG.md Co-authored-by: José Coto <jlcoto@users.noreply.github.com> Co-authored-by: Elize Papineau <elizepapineau@gmail.com> Co-authored-by: Elize Papineau <elize.papineau@dbtlabs.com> Co-authored-by: Joe Ste.Marie <stemarie.joe@gmail.com> Co-authored-by: Niall Woodward <niall@niallrees.com>
- Loading branch information
1 parent
14127aa
commit 46fcdf6
Showing
6 changed files
with
50 additions
and
1 deletion.
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,4 @@ | ||
key_name,static_col,num_rows | ||
abc,dbt,2 | ||
jkl,dbt,3 | ||
xyz,test,1 |
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
19 changes: 19 additions & 0 deletions
19
integration_tests/models/cross_db_utils/test_any_value.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,19 @@ | ||
with some_model as ( | ||
select 1 as id, 'abc' as key_name, 'dbt' as static_col union all | ||
select 2 as id, 'abc' as key_name, 'dbt' as static_col union all | ||
select 3 as id, 'jkl' as key_name, 'dbt' as static_col union all | ||
select 4 as id, 'jkl' as key_name, 'dbt' as static_col union all | ||
select 5 as id, 'jkl' as key_name, 'dbt' as static_col union all | ||
select 6 as id, 'xyz' as key_name, 'test' as static_col | ||
), | ||
|
||
final as ( | ||
select | ||
key_name, | ||
{{ dbt_utils.any_value('static_col') }} as static_col, | ||
count(id) as num_rows | ||
from some_model | ||
group by key_name | ||
) | ||
|
||
select * from final |
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,17 @@ | ||
{% macro any_value(expression) -%} | ||
{{ return(adapter.dispatch('any_value', 'dbt_utils') (expression)) }} | ||
{% endmacro %} | ||
|
||
|
||
{% macro default__any_value(expression) -%} | ||
|
||
any_value({{ expression }}) | ||
|
||
{%- endmacro %} | ||
|
||
|
||
{% macro postgres__any_value(expression) -%} | ||
{#- /*Postgres doesn't support any_value, so we're using min() to get the same result*/ -#} | ||
min({{ expression }}) | ||
|
||
{%- endmacro %} |