-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix/timestamp withought timezone (#458) * timestamp and changelog updates * changelog fix * Add context for why change to no timezone Co-authored-by: Joel Labes <[email protected]> * also ignore dbt_packages (#463) * also ignore dbt_packages * Update CHANGELOG.md * Update CHANGELOG.md Co-authored-by: Joel Labes <[email protected]> * date_spine: transform comment to jinja (#462) * Have union_relations raise exception when include parameter results in no columns (#473) * Raise exception if no columns in column_superset * Add relation names to compiler error message * Add `union_relations` fix to changelog * Added case for handling postgres foreign tables... (#476) * Add link for fewer_rows_than schema test in docs (#465) * Added case for handling postgres foreign tables (tables which are external to current database and are imported into current database from remote data stores by using Foreign Data Wrappers functionallity). * Reworked getting of postges table_type. * Added needed changes to CHANGELOG. Co-authored-by: José Coto <[email protected]> Co-authored-by: Taras Stetsiak <[email protected]> * Enhance usability of star macro by only generating column aliases when prefix and/or suffix is specified (#468) * The star macro should only produce column aliases when there is either a prefix or suffix specified. * Enhanced the readme for the star macro. * Add new integration test Co-authored-by: Nick Perrott <[email protected]> Co-authored-by: Josh Elston-Green Co-authored-by: Joel Labes <[email protected]> * fix: extra brace typo in insert_by_period_materialization (#480) * Support quoted column names in sequential_values test (#479) * Add any value (#501) * 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 <[email protected]> * 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 <[email protected]> Co-authored-by: Elize Papineau <[email protected]> Co-authored-by: Elize Papineau <[email protected]> Co-authored-by: Joe Ste.Marie <[email protected]> Co-authored-by: Niall Woodward <[email protected]> * Fix changelog * Second take at fixing pivot to allow single quotes (#503) * fix pivot : in pivoted column value, single quote must be escaped (on postgresql) else ex. syntax error near : when color = 'blue's' * patched expected * single quote escape : added dispatched version of the macro to support bigquery & snowflake * second backslash to escape in Jinja, change case of test file columns Let's see if other databases allow this * explicitly list columns to compare * different tests for snowflake and others * specific comparison seed * Don't quote identifiers for apostrophe, to avoid BQ and SF problems * Whitespace management for macros * Update CHANGELOG.md Co-authored-by: Marc Dutoo <[email protected]> * Add bool or cross db (#504) * Create bool_or cross-db func * Forgot a comma * Update CHANGELOG.md * Code review tweaks Co-authored-by: Joe Markiewicz <[email protected]> Co-authored-by: Anders <[email protected]> Co-authored-by: Mikaël Simarik <[email protected]> Co-authored-by: Graham Wetzler <[email protected]> Co-authored-by: Taras <[email protected]> Co-authored-by: José Coto <[email protected]> Co-authored-by: Taras Stetsiak <[email protected]> Co-authored-by: nickperrott <[email protected]> Co-authored-by: Nick Perrott <[email protected]> Co-authored-by: Ted Conbeer <[email protected]> Co-authored-by: Armand Duijn <[email protected]> Co-authored-by: Elize Papineau <[email protected]> Co-authored-by: Elize Papineau <[email protected]> Co-authored-by: Joe Ste.Marie <[email protected]> Co-authored-by: Niall Woodward <[email protected]> Co-authored-by: Marc Dutoo <[email protected]>
- Loading branch information
1 parent
4ef456e
commit 45bd4ad
Showing
30 changed files
with
257 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
|
||
target/ | ||
dbt_modules/ | ||
dbt_packages/ | ||
logs/ | ||
venv/ | ||
venv/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
key,val1,val2 | ||
abc,1,1 | ||
abc,1,0 | ||
def,1,0 | ||
hij,1,1 | ||
hij,1, | ||
klm,1,0 | ||
klm,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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
key,value | ||
abc,true | ||
def,false | ||
hij,true | ||
klm,false |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
size,color | ||
S,red | ||
S,blue | ||
M,red | ||
S,blue's | ||
M,red |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
size,red,blue | ||
S,1,1 | ||
M,1,0 | ||
M,1,0 |
3 changes: 3 additions & 0 deletions
3
integration_tests/data/sql/data_pivot_expected_apostrophe.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,3 @@ | ||
size,red,blue,blues | ||
S,1,1,1 | ||
M,1,0,0 |
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 @@ | ||
group_field_1,group_field_2,value_field | ||
a,b,1 | ||
a,b,2 | ||
c,d,3 | ||
c,e,4 |
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 @@ | ||
group_field_1,group_field_2,value_field_sum | ||
a,b,3 | ||
c,d,3 | ||
c,e,4 |
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
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,5 @@ | ||
select | ||
key, | ||
{{ dbt_utils.bool_or('val1 = val2') }} as value | ||
from {{ ref('data_bool_or' )}} | ||
group by key |
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,17 @@ | ||
|
||
-- TODO: How do we make this work nicely on Snowflake too? | ||
|
||
{% if target.type == 'snowflake' %} | ||
{% set column_values = ['RED', 'BLUE', "BLUE'S"] %} | ||
{% set cmp = 'ilike' %} | ||
{% else %} | ||
{% set column_values = ['red', 'blue', "blue's"] %} | ||
{% set cmp = '=' %} | ||
{% endif %} | ||
|
||
select | ||
size, | ||
{{ dbt_utils.pivot('color', column_values, cmp=cmp, quote_identifiers=False) }} | ||
|
||
from {{ ref('data_pivot') }} | ||
group by size |
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 @@ | ||
/*This test checks that column aliases aren't applied unless there's a prefix/suffix necessary, to ensure that GROUP BYs keep working*/ | ||
|
||
{% set selected_columns = dbt_utils.star(from=ref('data_star_aggregate'), except=['value_field']) %} | ||
|
||
with data as ( | ||
|
||
select | ||
{{ selected_columns }}, | ||
sum(value_field) as value_field_sum | ||
|
||
from {{ ref('data_star_aggregate') }} | ||
group by {{ selected_columns }} | ||
|
||
) | ||
|
||
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,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 %} |
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,24 @@ | ||
{% macro bool_or(expression) -%} | ||
{{ return(adapter.dispatch('bool_or', 'dbt_utils') (expression)) }} | ||
{% endmacro %} | ||
|
||
|
||
{% macro default__bool_or(expression) -%} | ||
|
||
bool_or({{ expression }}) | ||
|
||
{%- endmacro %} | ||
|
||
|
||
{% macro snowflake__bool_or(expression) -%} | ||
|
||
boolor_agg({{ expression }}) | ||
|
||
{%- endmacro %} | ||
|
||
|
||
{% macro bigquery__bool_or(expression) -%} | ||
|
||
logical_or({{ expression }}) | ||
|
||
{%- 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,18 @@ | ||
{% macro escape_single_quotes(expression) %} | ||
{{ return(adapter.dispatch('escape_single_quotes', 'dbt_utils') (expression)) }} | ||
{% endmacro %} | ||
|
||
{# /*Default to replacing a single apostrophe with two apostrophes: they're -> they''re*/ #} | ||
{% macro default__escape_single_quotes(expression) -%} | ||
{{ expression | replace("'","''") }} | ||
{%- endmacro %} | ||
|
||
{# /*Snowflake uses a single backslash: they're -> they\'re. The second backslash is to escape it from Jinja */ #} | ||
{% macro snowflake__escape_single_quotes(expression) -%} | ||
{{ expression | replace("'", "\\'") }} | ||
{%- endmacro %} | ||
|
||
{# /*BigQuery uses a single backslash: they're -> they\'re. The second backslash is to escape it from Jinja */ #} | ||
{% macro bigquery__escape_single_quotes(expression) -%} | ||
{{ expression | replace("'", "\\'") }} | ||
{%- 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
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,22 @@ | ||
{%- macro get_table_types_sql() -%} | ||
{{ return(adapter.dispatch('get_table_types_sql', 'dbt_utils')()) }} | ||
{%- endmacro -%} | ||
|
||
{% macro default__get_table_types_sql() %} | ||
case table_type | ||
when 'BASE TABLE' then 'table' | ||
when 'EXTERNAL TABLE' then 'external' | ||
when 'MATERIALIZED VIEW' then 'materializedview' | ||
else lower(table_type) | ||
end as "table_type" | ||
{% endmacro %} | ||
|
||
|
||
{% macro postgres__get_table_types_sql() %} | ||
case table_type | ||
when 'BASE TABLE' then 'table' | ||
when 'FOREIGN' then 'external' | ||
when 'MATERIALIZED VIEW' then 'materializedview' | ||
else lower(table_type) | ||
end as "table_type" | ||
{% 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
Oops, something went wrong.