Skip to content

Commit 71d8d49

Browse files
Add files via upload
1 parent 8291ecc commit 71d8d49

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{{config(materialized = 'incremental'
2+
,incremental_strategy = 'merge'
3+
,alias = 'credit_consent_check_history'
4+
,unique_key = ['application_number','bureau_name','pulled_date']
5+
,tags = ['genpact']
6+
)
7+
}}
8+
9+
WITH
10+
11+
/*
12+
* WHEN WHO WHAT
13+
* ------------ -------------- --------------------------------------------------------------------------------------
14+
* 12-SEP-2024 PCROSS SNF-7100 initial
15+
* 18-SEP-2024 JSTOPANSKY SNF-7100 updating reference to external table instead of src table
16+
*
17+
* Note : table credit_consent_check_history is being incrementally updated ('merge') using data
18+
* in external table EXT_CREDIT_CONSENT_CHECK_HISTORY.
19+
* the external table is based on a csv file (genpact.csv) in AWS location "s3://prod-data-services-genpact/"
20+
* the loaded data is type VARIANT -> convert to VARCHAR
21+
*
22+
*/
23+
24+
ext AS (
25+
SELECT
26+
value:c1::VARCHAR AS application_number
27+
,value:c2::VARCHAR AS report_status
28+
,value:c3::VARCHAR AS bureau_name_hierarchy
29+
,value:c4::VARCHAR AS bureau_name
30+
,value:c5::VARCHAR AS score_band
31+
,value:c6::VARCHAR AS application_status
32+
,value:c7::VARCHAR AS pulled_date
33+
,value:c8::VARCHAR AS application_created_date
34+
,value:c9::VARCHAR AS score
35+
,value:c10::VARCHAR AS application_final_decision_date
36+
,value:c11::VARCHAR AS application_last_modified_date
37+
,value:c12::VARCHAR AS state
38+
,value:c13::VARCHAR AS zip
39+
,value:c14::VARCHAR AS bureau_dob_year
40+
,metadata$file_last_modified AS s3_last_modified_at
41+
FROM
42+
{{source('SRC_GENPACT','EXT_CREDIT_CONSENT_CHECK_HISTORY')}}
43+
{% if is_incremental() %}
44+
WHERE metadata$file_last_modified > (SELECT NVL(MAX(s3_last_modified_at), to_date('1999-01-01')) FROM {{this}})
45+
{% endif %}
46+
)
47+
48+
SELECT
49+
ext.application_number
50+
,ext.report_status
51+
,ext.bureau_name_hierarchy
52+
,ext.bureau_name
53+
,ext.score_band
54+
,ext.application_status
55+
,ext.pulled_date
56+
,ext.application_created_date
57+
,ext.score
58+
,ext.application_final_decision_date
59+
,ext.application_last_modified_date
60+
,ext.state
61+
,ext.zip
62+
,ext.bureau_dob_year
63+
,ext.s3_last_modified_at
64+
,current_timestamp() AS loaded_at
65+
66+
FROM ext

0 commit comments

Comments
 (0)