Skip to content

Commit

Permalink
Streamline code and clean it up.
Browse files Browse the repository at this point in the history
  • Loading branch information
VersusFacit committed Feb 17, 2022
1 parent 98ec610 commit e96e7ff
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 22 deletions.
3 changes: 3 additions & 0 deletions tests/integration/docs_generate_tests/test_docs_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ def rendered_model_config(self, **updates):
'full_refresh': None,
'on_schema_change': 'ignore',
'meta': {},
'unique_key': None
}
result.update(updates)
return result
Expand All @@ -358,6 +359,7 @@ def rendered_seed_config(self, **updates):
'schema': None,
'alias': None,
'meta': {},
'unique_key': None
}
result.update(updates)
return result
Expand Down Expand Up @@ -417,6 +419,7 @@ def rendered_tst_config(self, **updates):
'schema': 'dbt_test__audit',
'alias': None,
'meta': {},
'unique_key': None
}
result.update(updates)
return result
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- for comparing against auto-typed seeds

{{
config(
materialized='incremental',
unique_key=['state', 'county', 'city']
)
}}

select
state as state,
county as county,
city as city,
last_visit_date as last_visit_date
from {{ ref('seed') }}

{% if is_incremental() %}
where last_visit_date > (select max(last_visit_date) from {{ this }})
{% endif %}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- types needed to compare against expected model reliably

{{
config(
materialized='incremental',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ values ('WA','King','Seattle','2022-02-01');

insert into {schema}.seed
(state, county, city, last_visit_date)
values ('CA','San Francisco','San Francisco','2022-02-01');
values ('CA','Los Angeles','Los Angeles','2022-02-01');
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,11 @@ def run_incremental_match_test(
@use_profile('snowflake')
def test__snowflake_no_unique_keys(self):
'''with no unique keys, seed and model should match'''
incremental_model='no_unique_key'
seed='seed'

self.build_test_case(
seed=seed, incremental_model=incremental_model,
update_sql_file='add_new_rows', seed_expected_row_count=8
self.run_incremental_mirror_seed_test(
incremental_model='no_unique_key',
seed='seed',
seed_expected_row_count=8
)
self.run_incremental_update(incremental_model=incremental_model)

self.assertTablesEqual(seed, incremental_model)


class TestIncrementalStrUniqueKey(TestIncrementalUniqueKey):
Expand All @@ -94,16 +89,6 @@ def test__snowflake_empty_str_unique_key(self):
seed='seed',
seed_expected_row_count=8
)
incremental_model=''
seed='seed'

self.build_test_case(
seed=seed, incremental_model=incremental_model,
update_sql_file='add_new_rows', seed_expected_row_count=8
)
self.run_incremental_update(incremental_model=incremental_model)

self.assertTablesEqual(seed, incremental_model)

@use_profile('snowflake')
def test__snowflake_one_unique_key(self):
Expand Down Expand Up @@ -166,8 +151,8 @@ def test__snowflake_trinary_unique_key_list(self):
def test__snowflake_unique_key_list_no_update(self):
'''with a fitting unique key, model will not overwrite existing row'''
self.run_incremental_mirror_seed_test(
incremental_model='trinary_unique_key_list',
update_sql_file='add_new_rows',
incremental_model='nontyped_trinary_unique_key_list',
seed='seed',
seed_expected_row_count=8
)

Expand Down

0 comments on commit e96e7ff

Please sign in to comment.