-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added partition by in lag tests (#146)
* Added partition by parameter * Added documentation * Modified the test to accept list instead of string * created data and implemented tests * corrected test in yml * Update formatting, test data and test macro Co-authored-by: clausherther <[email protected]>
- Loading branch information
1 parent
b5a022d
commit 13eb72c
Showing
7 changed files
with
115 additions
and
17 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 |
---|---|---|
@@ -1,3 +1,20 @@ | ||
{% if execute %} | ||
{%- set source_relation = adapter.get_relation( | ||
database="bigquery-public-data", | ||
schema="new_york_citibike", | ||
identifier="citibike_trips") -%} | ||
|
||
{{ log("Source Relation: " ~ source_relation, info=true) }} | ||
{% endif %} | ||
|
||
{% if execute %} | ||
{%- set source_relation_2 = adapter.get_relation( | ||
database=this.database, | ||
schema=this.schema, | ||
identifier=this.name) -%} | ||
|
||
{{ log("Source Relation: " ~ source_relation_2, info=true) }} | ||
{% endif %} | ||
select | ||
'[email protected]' as email_address, | ||
'@[^.]*' as reg_exp | ||
|
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
48 changes: 48 additions & 0 deletions
48
integration_tests/models/schema_tests/window_function_test.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,48 @@ | ||
with data_example as ( | ||
|
||
select | ||
1 as idx, | ||
'2020-10-21' as date_col, | ||
cast(0 as {{ dbt_utils.type_float() }}) as col_numeric_a | ||
|
||
union all | ||
|
||
select | ||
2 as idx, | ||
'2020-10-22' as date_col, | ||
1 as col_numeric_a | ||
|
||
union all | ||
|
||
select | ||
2 as idx, | ||
'2020-10-23' as date_col, | ||
2 as col_numeric_a | ||
|
||
union all | ||
|
||
select | ||
2 as idx, | ||
'2020-10-24' as date_col, | ||
1 as col_numeric_a | ||
|
||
union all | ||
|
||
select | ||
3 as idx, | ||
'2020-10-23' as date_col, | ||
0.5 as col_numeric_a | ||
union all | ||
|
||
select | ||
4 as idx, | ||
'2020-10-23' as date_col, | ||
0.5 as col_numeric_a | ||
|
||
) | ||
select | ||
*, | ||
sum(col_numeric_a) over (partition by idx order by date_col) as rolling_sum_increasing, | ||
sum(col_numeric_a) over (partition by idx order by date_col desc) as rolling_sum_decreasing | ||
from | ||
data_example |
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