-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
683abae
commit aefe4f0
Showing
15 changed files
with
219 additions
and
34 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
5 changes: 5 additions & 0 deletions
5
integration_tests/data/incremental_hooks/data_get_incremental_manifest_status_t.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 @@ | ||
model,first_processed_load_tstamp,last_processed_load_tstamp | ||
a,2020-01-01 00:00:00,2020-01-02 00:00:00 | ||
b,2020-01-02 00:00:00,2020-01-03 00:00:00 | ||
c,2020-01-03 00:00:00,2020-01-04 00:00:00 | ||
d,2020-01-01 00:00:00,2020-01-02 00:00:00 |
3 changes: 3 additions & 0 deletions
3
integration_tests/data/incremental_hooks/data_get_incremental_manifest_status_t_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,3 @@ | ||
test_case,min_first_processed_load_tstamp,max_first_processed_load_tstamp,min_last_processed_load_tstamp,max_last_processed_load_tstamp,models_matched_from_manifest,sync_count,has_matched_all_models | ||
all model_in_run exist in manifest,2020-01-01 00:00:00,2020-01-03 00:00:00,2020-01-02 00:00:00,2020-01-04 00:00:00,3,3,true | ||
some model_in_run exist in manifest,2020-01-01 00:00:00,2020-01-03 00:00:00,2020-01-02 00:00:00,2020-01-03 00:00:00,2,2,false |
9 changes: 9 additions & 0 deletions
9
integration_tests/data/incremental_hooks/data_get_run_limits_t.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,9 @@ | ||
min_last_processed_load_tstamp,max_last_processed_load_tstamp,models_matched_from_manifest,has_matched_all_models,sync_count,start_date,lower_limit,upper_limit | ||
,,0,FALSE,0,2021-01-01,2021-01-01 00:00:00+00:00,2021-01-31 00:00:00+00:00 | ||
2021-03-01 00:00:00+00:00,2021-03-01 00:00:00+00:00,10,FALSE,1,2021-01-01,2021-01-01 00:00:00+00:00,2021-01-31 00:00:00+00:00 | ||
2021-03-01 18:00:00+00:00,2021-03-01 18:00:00+00:00,10,TRUE,1,2021-01-01,2021-03-01 18:00:00+00:00,2021-03-31 18:00:00+00:00 | ||
2021-03-01 00:00:00+00:00,2021-03-01 00:00:00+00:00,10,FALSE,2,2021-01-01,1999-01-01 00:00:00+00:00,1999-01-02 00:00:00+00:00 | ||
2021-03-01 00:00:00+00:00,2021-03-01 00:00:00+00:00,10,FALSE,3,2021-01-01,1999-01-01 00:00:00+00:00,1999-01-02 00:00:00+00:00 | ||
2021-03-01 00:00:00+00:00,2021-03-05 00:00:00+00:00,10,TRUE,3,2021-01-01,1999-01-01 00:00:00+00:00,1999-01-02 00:00:00+00:00 | ||
2021-03-01 00:00:00+00:00,2021-05-01 00:00:00+00:00,10,TRUE,3,2021-01-01,1999-01-01 00:00:00+00:00,1999-01-02 00:00:00+00:00 | ||
2021-03-01 00:00:00+00:00,2021-03-01 00:00:00+00:00,10,TRUE,3,2021-01-01,1999-01-01 00:00:00+00:00,1999-01-02 00:00:00+00:00 |
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
10 changes: 0 additions & 10 deletions
10
integration_tests/models/incremental_hooks/incremental_hooks.yml
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
7 changes: 7 additions & 0 deletions
7
integration_tests/models/unit_tests/test_get_incremental_manifest_status_macro/schema.yml
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,7 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: test_get_incremental_manifest_status_macro | ||
tests: | ||
- dbt_utils.equality: | ||
compare_model: ref('data_get_incremental_manifest_status_expected') |
File renamed without changes.
7 changes: 7 additions & 0 deletions
7
integration_tests/models/unit_tests/test_get_incremental_manifest_status_t_macro/schema.yml
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,7 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: test_get_incremental_manifest_status_t_macro | ||
tests: | ||
- dbt_utils.equality: | ||
compare_model: ref('data_get_incremental_manifest_status_t_expected') |
46 changes: 46 additions & 0 deletions
46
..._get_incremental_manifest_status_t_macro/test_get_incremental_manifest_status_t_macro.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,46 @@ | ||
{# | ||
Copyright (c) 2021-present Snowplow Analytics Ltd. All rights reserved. | ||
This program is licensed to you under the Snowplow Personal and Academic License Version 1.0, | ||
and you may not use this file except in compliance with the Snowplow Personal and Academic License Version 1.0. | ||
You may obtain a copy of the Snowplow Personal and Academic License Version 1.0 at https://docs.snowplow.io/personal-and-academic-license-1.0/ | ||
#} | ||
|
||
{%- set all_models = snowplow_utils.get_incremental_manifest_status_t(ref('data_get_incremental_manifest_status_t'), ['a','b','c']) -%} | ||
{%- set partial_models = snowplow_utils.get_incremental_manifest_status_t(ref('data_get_incremental_manifest_status_t'), ['b','d','e']) -%} | ||
|
||
with prep as ( | ||
select | ||
'all model_in_run exist in manifest' as test_case, | ||
{{ snowplow_utils.cast_to_tstamp(all_models[0]) }} as min_first_processed_load_tstamp, | ||
{{ snowplow_utils.cast_to_tstamp(all_models[1]) }} as max_first_processed_load_tstamp, | ||
{{ snowplow_utils.cast_to_tstamp(all_models[2]) }} as min_last_processed_load_tstamp, | ||
{{ snowplow_utils.cast_to_tstamp(all_models[3]) }} as max_last_processed_load_tstamp, | ||
{{all_models[4]}} as models_matched_from_manifest, | ||
{{all_models[5]}} as sync_count, | ||
{{all_models[6]}} as has_matched_all_models | ||
|
||
union all | ||
|
||
select | ||
'some model_in_run exist in manifest' as test_case, | ||
{{ snowplow_utils.cast_to_tstamp(all_models[0]) }} as min_first_processed_load_tstamp, | ||
{{ snowplow_utils.cast_to_tstamp(all_models[1]) }} as max_first_processed_load_tstamp, | ||
{{ snowplow_utils.cast_to_tstamp(partial_models[2]) }} as min_last_processed_load_tstamp, | ||
{{ snowplow_utils.cast_to_tstamp(partial_models[3]) }} as max_last_processed_load_tstamp, | ||
{{partial_models[4]}} as models_matched_from_manifest, | ||
{{partial_models[5]}} as sync_count, | ||
{{partial_models[6]}} as has_matched_all_models | ||
|
||
) | ||
|
||
select | ||
test_case, | ||
min_first_processed_load_tstamp, | ||
max_first_processed_load_tstamp, | ||
min_last_processed_load_tstamp, | ||
max_last_processed_load_tstamp, | ||
models_matched_from_manifest, | ||
sync_count, | ||
cast(has_matched_all_models as {{ dbt.type_boolean() }}) as has_matched_all_models | ||
|
||
from prep |
9 changes: 9 additions & 0 deletions
9
integration_tests/models/unit_tests/test_get_run_limits_macro/schema.yml
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,9 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: test_get_run_limits_macro | ||
tests: | ||
- dbt_utils.expression_is_true: | ||
expression: "expected_lower_limit = actual_lower_limit" | ||
- dbt_utils.expression_is_true: | ||
expression: "expected_upper_limit = actual_upper_limit" |
File renamed without changes.
9 changes: 9 additions & 0 deletions
9
integration_tests/models/unit_tests/test_get_run_limits_t_macro/schema.yml
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,9 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: test_get_run_limits_t_macro | ||
tests: | ||
- dbt_utils.expression_is_true: | ||
expression: "expected_lower_limit = actual_lower_limit" | ||
- dbt_utils.expression_is_true: | ||
expression: "expected_upper_limit = actual_upper_limit" |
55 changes: 55 additions & 0 deletions
55
...ation_tests/models/unit_tests/test_get_run_limits_t_macro/test_get_run_limits_t_macro.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,55 @@ | ||
{# | ||
Copyright (c) 2021-present Snowplow Analytics Ltd. All rights reserved. | ||
This program is licensed to you under the Snowplow Personal and Academic License Version 1.0, | ||
and you may not use this file except in compliance with the Snowplow Personal and Academic License Version 1.0. | ||
You may obtain a copy of the Snowplow Personal and Academic License Version 1.0 at https://docs.snowplow.io/personal-and-academic-license-1.0/ | ||
#} | ||
|
||
{%- set data_query -%} | ||
select * from {{ ref('data_get_run_limits_t') }} | ||
{%- endset -%} | ||
|
||
{# fetch test data set as dict. dict form {column_name: (tuple_of_results) #} | ||
{%- set raw_test_data = dbt_utils.get_query_results_as_dict(data_query) -%} | ||
|
||
{# Snowflake returns keys as uppercase. Iterate and set to lowercase #} | ||
{% set test_data = {} %} | ||
{% for key, value in raw_test_data.items() %} | ||
{% do test_data.update({key.lower(): value}) %} | ||
{% endfor %} | ||
|
||
{% for i in range(test_data.min_last_processed_load_tstamp|length) %} | ||
|
||
{# iteratively pass each row of test data into get_run_limits_t() and execute returned query | ||
min_first_processed_load_tstamp and max_first_processed_load_tstamp are not yet used, placeholder in place #} | ||
{%- set results = run_query(snowplow_utils.get_run_limits_t('9999-01-01 00:00:00', | ||
'9999-01-01 00:00:00', | ||
test_data.min_last_processed_load_tstamp[i], | ||
test_data.max_last_processed_load_tstamp[i], | ||
test_data.models_matched_from_manifest[i], | ||
test_data.sync_count[i], | ||
test_data.has_matched_all_models[i], | ||
test_data.start_date[i])) -%} | ||
|
||
{# expected limits taken from test data #} | ||
{%- set expected_lower_limit = test_data.lower_limit[i] -%} | ||
{%- set expected_upper_limit = test_data.upper_limit[i] -%} | ||
|
||
{# actual limits taken from get_run_limits_t() results #} | ||
{%- if execute -%} | ||
{%- set actual_lower_limit = results.columns[0].values()[0] -%} | ||
{%- set actual_upper_limit = results.columns[1].values()[0] -%} | ||
{%- else -%} | ||
{%- set actual_lower_limit = none -%} | ||
{%- set actual_upper_limit = none -%} | ||
{%- endif -%} | ||
|
||
{# union expected vs. actual for each test case #} | ||
select | ||
{{snowplow_utils.cast_to_tstamp(expected_lower_limit)}} as expected_lower_limit, | ||
{{snowplow_utils.cast_to_tstamp(expected_upper_limit)}} as expected_upper_limit, | ||
{{snowplow_utils.cast_to_tstamp(actual_lower_limit)}} as actual_lower_limit, | ||
{{snowplow_utils.cast_to_tstamp(actual_upper_limit)}} as actual_upper_limit | ||
{% if not loop.last %} union all {% endif %} | ||
|
||
{% endfor %} |
This file was deleted.
Oops, something went wrong.