-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_validation_all_col.sql
58 lines (51 loc) · 1.55 KB
/
get_validation_all_col.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{% macro get_validation_all_col(
dbt_identifier,
old_database,
old_schema,
old_identifier,
primary_keys,
exclude_columns=[],
summarize=true
) %}
{{ return(adapter.dispatch('get_validation_all_col', 'audit_helper_ext')
(
dbt_identifier=dbt_identifier,
old_database=old_database,
old_schema=old_schema,
old_identifier=old_identifier,
primary_keys=primary_keys,
exclude_columns=exclude_columns,
summarize=summarize
)
) }}
{% endmacro %}
{% macro default__get_validation_all_col(
dbt_identifier,
old_database,
old_schema,
old_identifier,
primary_keys,
exclude_columns,
summarize
) %}
{% set old_relation = adapter.get_relation(
database=old_database,
schema=old_schema,
identifier=old_identifier
) %}
{% set dbt_relation = ref(dbt_identifier) %}
{% set audit_query = audit_helper.compare_all_columns(
a_relation=old_relation,
b_relation=dbt_relation,
exclude_columns=exclude_columns,
primary_key=dbt_utils.generate_surrogate_key(primary_keys),
summarize=summarize
) %}
{% if execute %}
{{ log('ℹ️ Those columns are excluded from the comparison: ' ~ exclude_columns, true) }}
{% set audit_results = audit_helper_ext.run_audit_query(audit_query, summarize) %}
{% if summarize %}
{{ audit_helper_ext.log_validation_result('all_col', audit_results, dbt_identifier, dbt_relation, old_relation) }}
{% endif %}
{% endif %}
{% endmacro %}