-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port tests for unique_key as a list. (#62)
### Description Ports tests for "unique_key as a list" from dbt-labs/dbt-spark#291.
- Loading branch information
Showing
17 changed files
with
648 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
tests/integration/incremental_unique_id_test/models/duplicated_unary_unique_key_list.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,17 @@ | ||
{{ | ||
config( | ||
materialized='incremental', | ||
unique_key=['state', 'state'] | ||
) | ||
}} | ||
|
||
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 %} |
14 changes: 14 additions & 0 deletions
14
tests/integration/incremental_unique_id_test/models/empty_str_unique_key.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,14 @@ | ||
{{ | ||
config( | ||
materialized='incremental', | ||
unique_key='' | ||
) | ||
}} | ||
|
||
select | ||
* | ||
from {{ ref('seed') }} | ||
|
||
{% if is_incremental() %} | ||
where last_visit_date > (select max(last_visit_date) from {{ this }}) | ||
{% endif %} |
12 changes: 12 additions & 0 deletions
12
tests/integration/incremental_unique_id_test/models/empty_unique_key_list.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,12 @@ | ||
{{ | ||
config( | ||
materialized='incremental', | ||
unique_key=[] | ||
) | ||
}} | ||
|
||
select * from {{ ref('seed') }} | ||
|
||
{% if is_incremental() %} | ||
where last_visit_date > (select max(last_visit_date) from {{ this }}) | ||
{% endif %} |
21 changes: 21 additions & 0 deletions
21
tests/integration/incremental_unique_id_test/models/expected/one_str__overwrite.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,21 @@ | ||
{{ | ||
config( | ||
materialized='table' | ||
) | ||
}} | ||
|
||
select | ||
'CT' as state, | ||
'Hartford' as county, | ||
'Hartford' as city, | ||
cast('2022-02-14' as date) as last_visit_date | ||
union all | ||
select 'MA','Suffolk','Boston',cast('2020-02-12' as date) | ||
union all | ||
select 'NJ','Mercer','Trenton',cast('2022-01-01' as date) | ||
union all | ||
select 'NY','Kings','Brooklyn',cast('2021-04-02' as date) | ||
union all | ||
select 'NY','New York','Manhattan',cast('2021-04-01' as date) | ||
union all | ||
select 'PA','Philadelphia','Philadelphia',cast('2021-05-21' as date) |
21 changes: 21 additions & 0 deletions
21
...gration/incremental_unique_id_test/models/expected/unique_key_list__inplace_overwrite.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,21 @@ | ||
{{ | ||
config( | ||
materialized='table' | ||
) | ||
}} | ||
|
||
select | ||
'CT' as state, | ||
'Hartford' as county, | ||
'Hartford' as city, | ||
cast('2022-02-14' as date) as last_visit_date | ||
union all | ||
select 'MA','Suffolk','Boston',cast('2020-02-12' as date) | ||
union all | ||
select 'NJ','Mercer','Trenton',cast('2022-01-01' as date) | ||
union all | ||
select 'NY','Kings','Brooklyn',cast('2021-04-02' as date) | ||
union all | ||
select 'NY','New York','Manhattan',cast('2021-04-01' as date) | ||
union all | ||
select 'PA','Philadelphia','Philadelphia',cast('2021-05-21' as date) |
13 changes: 13 additions & 0 deletions
13
tests/integration/incremental_unique_id_test/models/no_unique_key.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,13 @@ | ||
{{ | ||
config( | ||
materialized='incremental' | ||
) | ||
}} | ||
|
||
select | ||
* | ||
from {{ ref('seed') }} | ||
|
||
{% if is_incremental() %} | ||
where last_visit_date > (select max(last_visit_date) from {{ this }}) | ||
{% endif %} |
19 changes: 19 additions & 0 deletions
19
tests/integration/incremental_unique_id_test/models/nontyped_trinary_unique_key_list.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 @@ | ||
-- 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 %} |
14 changes: 14 additions & 0 deletions
14
tests/integration/incremental_unique_id_test/models/not_found_unique_key.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,14 @@ | ||
{{ | ||
config( | ||
materialized='incremental', | ||
unique_key='thisisnotacolumn' | ||
) | ||
}} | ||
|
||
select | ||
* | ||
from {{ ref('seed') }} | ||
|
||
{% if is_incremental() %} | ||
where last_visit_date > (select max(last_visit_date) from {{ this }}) | ||
{% endif %} |
8 changes: 8 additions & 0 deletions
8
tests/integration/incremental_unique_id_test/models/not_found_unique_key_list.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,8 @@ | ||
{{ | ||
config( | ||
materialized='incremental', | ||
unique_key=['state', 'thisisnotacolumn'] | ||
) | ||
}} | ||
|
||
select * from {{ ref('seed') }} |
17 changes: 17 additions & 0 deletions
17
tests/integration/incremental_unique_id_test/models/str_unique_key.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,17 @@ | ||
{{ | ||
config( | ||
materialized='incremental', | ||
unique_key='state' | ||
) | ||
}} | ||
|
||
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 %} |
19 changes: 19 additions & 0 deletions
19
tests/integration/incremental_unique_id_test/models/trinary_unique_key_list.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 @@ | ||
-- types needed to compare against expected model reliably | ||
|
||
{{ | ||
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 %} |
17 changes: 17 additions & 0 deletions
17
tests/integration/incremental_unique_id_test/models/unary_unique_key_list.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,17 @@ | ||
{{ | ||
config( | ||
materialized='incremental', | ||
unique_key=['state'] | ||
) | ||
}} | ||
|
||
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 %} |
9 changes: 9 additions & 0 deletions
9
tests/integration/incremental_unique_id_test/seeds/add_new_rows.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,9 @@ | ||
-- insert two new rows, both of which should be in incremental model | ||
-- with any unique columns | ||
insert into {schema}.seed | ||
(state, county, city, last_visit_date) | ||
values ('WA','King','Seattle',cast('2022-02-01' as date)); | ||
|
||
insert into {schema}.seed | ||
(state, county, city, last_visit_date) | ||
values ('CA','Los Angeles','Los Angeles',cast('2022-02-01' as date)); |
5 changes: 5 additions & 0 deletions
5
tests/integration/incremental_unique_id_test/seeds/duplicate_insert.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,5 @@ | ||
-- insert new row, which should not be in incremental model | ||
-- with primary or first three columns unique | ||
insert into {schema}.seed | ||
(state, county, city, last_visit_date) | ||
values ('CT','Hartford','Hartford',cast('2022-02-14' as date)); |
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 @@ | ||
state,county,city,last_visit_date | ||
CT,Hartford,Hartford,2020-09-23 | ||
MA,Suffolk,Boston,2020-02-12 | ||
NJ,Mercer,Trenton,2022-01-01 | ||
NY,Kings,Brooklyn,2021-04-02 | ||
NY,New York,Manhattan,2021-04-01 | ||
PA,Philadelphia,Philadelphia,2021-05-21 |
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 | ||
|
||
seeds: | ||
- name: seed | ||
config: | ||
column_types: | ||
last_visit_date: date |
Oops, something went wrong.