-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.sql
More file actions
75 lines (50 loc) · 2.57 KB
/
script.sql
File metadata and controls
75 lines (50 loc) · 2.57 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
-- drop schema balboa_dev.gomezn;
-- =================================================================================
-- Enable Change tracking on raw table
-- =================================================================================
use role loader;
-- source table needs to have change tracking enabled for dynamic tables to refresh
alter table RAW.LOANS.PERSONAL_LOANS set CHANGE_TRACKING = true;
-- =================================================================================
-- First clear out non CA records from source table
-- =================================================================================
use role loader;
delete
from raw.loans.personal_loans
where addr_state != 'CA';
-- =================================================================================
-- Perform dbt build
-- =================================================================================
/*
cd /config/workspace/transform && dbt build --vars '{"persist_tests": "true", "tests_model": "test_failures"}'
*/
show views in schema balboa_dev.gomezn
->> select "name" from $1;
show tables in schema balboa_dev.gomezn
->> select "name" from $1;
show dynamic tables in schema balboa_dev.gomezn
->> select "name", "rows", "target_lag","refresh_mode","refresh_mode_reason","warehouse" from $1;
-- =================================================================================
-- Show that we only have California in the raw and in the dynamic staging table
-- =================================================================================
-- raw data
select distinct addr_state from raw.loans.personal_loans;
-- dynamic table with a target lag = downstream
select distinct addr_state from BALBOA_DEV.GOMEZN.STG_PERSONAL_LOANS;
-- There are no errors in the errors view summary
select * from balboa_dev.gomezn.stg_test_failures;
-- =================================================================================
-- Reload the data with dlt
-- =================================================================================
/*
/config/workspace/load/dlt/loans_data.py
*/
-- =================================================================================
-- Show that now we have many states and hence errors
-- =================================================================================
-- raw data
select distinct addr_state from raw.loans.personal_loans;
-- dynamic table with a target lag = downstream
select distinct addr_state from BALBOA_DEV.GOMEZN.STG_PERSONAL_LOANS;
-- There are no errors in the errors view summary
select * from balboa_dev.gomezn.stg_test_failures;