-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add new macros for diff calculation, and unit tests (#99) * Add macro for new hash-based comparison strategy * split out SF-focused version of macro * Fix change to complex object * Fix overuse of star * switch from compare rels to compare queries * provide wrapping parens * switch to array of columns for PK * split unit tests into own files, change unit tests to array pk * tidy up get_comp_bounds * fix arg rename * add quick_are_queries_identical and unit tests * Move data tests into own directory * Add test for multiple PKs * fix incorrect unit test configs * make data types for id and id_2 big enough nums * Mock event_time response * fix hardcoded value in quick_are_qs_identical * Add unit tests for null handling (still broken) * Rename columsn to be more unique * Steal surrogate key macro from utils * Use generated surrogate key across the board in place of PK * rm my profile reference * Update quick_are_queries_identical.sql * Add diagram explaining comparison bounds * Add comments explaining warehouse-specific optimisations * cross-db support * subq * no postgres or redshift for a sec * add default var values for compare wrappers * avoid lateral alias reference for BQ * BQ doesn't support count(arg1, arg2) * re-enable redshift * Alias subq for redshift * remove extra comma * add row status of nonunique_pk * remove redundant test and wrapper model * Create json-y tests for snowflake * Add workaround for redshift to support count num rows in status * skip incompatible tests * Fix redshift lack of bool_or support in window funcs * add skip exclusions for everything else * fix incorrect skip tag application * Move user configs to project.yml from profiles * Temporarily disable unpassable redshift tests * add temp skip to circle's config.yml * forgot tag: method * Temporarily skip reworked_compare_all_statuses_different_column_set * Skip another test redshift * disable unsupported tests BQ * postgres too? * Fixes for postgres * namespace macros * It's a postgres problem, not a redshift problem * Handle postgres 63 char limit * Add databricks * Rename tests to data_tests * Found a better workaround for missing count distinct window * actually call the macro * disable syntax-failing tests on dbx * try to install core from main to get sorting fix * Revert "try to install core from main to get sorting fix" This reverts commit d28f3e1. * Audit helper code review changes * add BQ support for qucik are queries identical * explain why using dense_rank * remove the compile step to avoid compilation error * Don't throw incompatible quick compare error during parse * add where clause to check we're not assuming its absence * enable first basic struct tests * Skip raising exception during parsing * json_build_object doesn't work on rs * changed behaviour redshift * skip complex structs on rs for now * temp disable all complex structs * skip some currently failoing bq tests * Properly exclude tests to skip, add comments * dbx too * rename reworked_compare to compare_and_classify_query_results * Rename files * rename macro file * Add relation_focused macros * Add BQ-specific generate_set_results for hashes, enable json tests * Implement hash comparisons for BQ and DBX (#103) * disable tests for unrelated adapters * Avoid lateral column aliasing * First cross-db complex struct fixture * Add final fixtures * Initial work on dbx compatibility * remove lateral column alias dbx * cast everything as string before hashing * add comment, enable all tests again * rename to dbt_audit_in_a instead of in_a * Protect against missing PK columns * gitignore package-lock.yml * add dbx variant of simple structs * Rename private macros to have _ prefix * Fix get comparison bounds (#104) * change to getting comparison bounds for queries not relations * add test for introspective queries * Make compare query columns multi pk (#105) * rm packagelock.yml
- Loading branch information
Showing
64 changed files
with
1,752 additions
and
106 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
target/ | ||
dbt_packages/ | ||
logs/ | ||
logfile | ||
logfile | ||
.DS_Store | ||
package-lock.yml | ||
integration_tests/package-lock.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,21 @@ | ||
{ | ||
"yaml.schemas": { | ||
"https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/latest/dbt_yml_files-latest.json": [ | ||
"/**/*.yml", | ||
"!profiles.yml", | ||
"!dbt_project.yml", | ||
"!packages.yml", | ||
"!selectors.yml", | ||
"!profile_template.yml" | ||
], | ||
"https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/latest/dbt_project-latest.json": [ | ||
"dbt_project.yml" | ||
], | ||
"https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/latest/selectors-latest.json": [ | ||
"selectors.yml" | ||
], | ||
"https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/latest/packages-latest.json": [ | ||
"packages.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
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
26 changes: 26 additions & 0 deletions
26
integration_tests/macros/unit_tests/struct_generation_macros.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,26 @@ | ||
{%- macro _basic_json_function() -%} | ||
{%- if target.type == 'snowflake' -%} | ||
object_construct | ||
{%- elif target.type == 'bigquery' -%} | ||
json_object | ||
{%- elif target.type == 'databricks' -%} | ||
map | ||
{%- elif execute -%} | ||
{# Only raise exception if it's actually being called, not during parsing #} | ||
{%- do exceptions.raise_compiler_error("Unknown adapter '"~ target.type ~ "'") -%} | ||
{%- endif -%} | ||
{%- endmacro -%} | ||
|
||
{% macro _complex_json_function(json) %} | ||
|
||
{% if target.type == 'redshift' %} | ||
json_parse({{ json }}) | ||
{% elif target.type == 'databricks' %} | ||
from_json({{ json }}, schema_of_json({{ json }})) | ||
{% elif target.type in ['snowflake', 'bigquery'] %} | ||
parse_json({{ json }}) | ||
{% elif execute %} | ||
{# Only raise exception if it's actually being called, not during parsing #} | ||
{%- do exceptions.raise_compiler_error("Unknown adapter '"~ target.type ~ "'") -%} | ||
{% endif %} | ||
{% endmacro %} |
18 changes: 0 additions & 18 deletions
18
integration_tests/models/compare_which_columns_differ_exclude_cols.sql
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions
11
integration_tests/models/data_tests/compare_and_classify_query_results.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,11 @@ | ||
-- this has no tests, it's just making sure that the introspecive queries for event_time actually run | ||
|
||
{{ | ||
audit_helper.compare_and_classify_query_results( | ||
a_query="select * from " ~ ref('unit_test_model_a') ~ " where 1=1", | ||
b_query="select * from " ~ ref('unit_test_model_b') ~ " where 1=1", | ||
primary_key_columns=['id'], | ||
columns=['id', 'col1', 'col2'], | ||
event_time='created_at' | ||
) | ||
}} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
25 changes: 25 additions & 0 deletions
25
integration_tests/models/data_tests/compare_which_columns_differ_exclude_cols.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,25 @@ | ||
{% set a_relation=ref('data_compare_which_columns_differ_a')%} | ||
|
||
{% set b_relation=ref('data_compare_which_columns_differ_b') %} | ||
|
||
{% set pk_cols = ['id'] %} | ||
{% set cols = ['id','value_changes','becomes_not_null','does_not_change'] %} | ||
|
||
{% if target.type == 'snowflake' %} | ||
{% set pk_cols = pk_cols | map("upper") | list %} | ||
{% set cols = cols | map("upper") | list %} | ||
{% endif %} | ||
|
||
select | ||
lower(column_name) as column_name, | ||
has_difference | ||
from ( | ||
|
||
{{ audit_helper.compare_which_relation_columns_differ( | ||
a_relation=a_relation, | ||
b_relation=b_relation, | ||
primary_key_columns=pk_cols, | ||
columns=cols | ||
) }} | ||
|
||
) as macro_output |
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
1 change: 1 addition & 0 deletions
1
integration_tests/models/unit_test_placeholder_models/unit_test_model_a.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 @@ | ||
select 12 as id, 22 as id_2, 'xyz' as col1, 'tuv' as col2, 123 as col3, {{ dbt.current_timestamp() }} as created_at |
1 change: 1 addition & 0 deletions
1
integration_tests/models/unit_test_placeholder_models/unit_test_model_b.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 @@ | ||
select 12 as id, 22 as id_2, 'xyz' as col1, 'tuv' as col2, 123 as col3, {{ dbt.current_timestamp() }} as created_at |
Oops, something went wrong.