-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test neighborhood codes in
iasworld.pardat.nbhd
(#103)
* Add column_is_subset_of_external_column dbt generic test and use it to test pardat.nbhd * Limit pardat_nbhd_matches_spatial_town_nbhd results to filter out years and dummy codes * Don't cast taxyr to int in pardat nbhd test filter condition Co-authored-by: Dan Snow <31494343+dfsnow@users.noreply.github.com> --------- Co-authored-by: Dan Snow <31494343+dfsnow@users.noreply.github.com>
- Loading branch information
1 parent
8e7a22f
commit 96d2f62
Showing
2 changed files
with
41 additions
and
0 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
28 changes: 28 additions & 0 deletions
28
dbt/tests/generic/test_column_is_subset_of_external_column.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,28 @@ | ||
-- Test that a given column is a subset of a column in an external relation. | ||
-- | ||
-- Returns rows where `column` has no matches in the external relation, with | ||
-- additional return columns drawn from the base relation as specified by | ||
-- `additional_select_columns`. | ||
{% test column_is_subset_of_external_column( | ||
model, | ||
column, | ||
external_model, | ||
external_column, | ||
additional_select_columns=[] | ||
) %} | ||
|
||
{%- set additional_select_columns_csv = additional_select_columns | join(", ") %} | ||
{%- set columns_csv = additional_select_columns_csv ~ ", " ~ column %} | ||
|
||
with | ||
distinct_external_values as ( | ||
select distinct ({{ external_column }}) as external_column | ||
from {{ external_model }} | ||
) | ||
select {{ columns_csv }} | ||
from {{ model }} | ||
left join | ||
distinct_external_values dist_ext on {{ column }} = dist_ext.external_column | ||
where dist_ext.external_column is null | ||
|
||
{% endtest %} |