-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_validation_full.sql
59 lines (52 loc) · 1.58 KB
/
get_validation_full.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
59
{% macro get_validation_full(
dbt_identifier,
old_database,
old_schema,
old_identifier,
primary_keys,
exclude_columns=[],
summarize=true
) %}
{{ return(adapter.dispatch('get_validation_full', '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_full(
dbt_identifier,
old_database,
old_schema,
old_identifier,
primary_keys,
exclude_columns=[],
summarize=true
) %}
{% 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_relations(
a_relation = old_relation,
b_relation = dbt_relation,
exclude_columns = exclude_columns,
primary_key = dbt_utils.generate_surrogate_key(primary_keys),
summarize = summarize,
limit = 100
) %}
{% 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('full', audit_results, dbt_identifier, dbt_relation, old_relation) }}
{% endif %}
{% endif %}
{% endmacro %}