Conversation
… model (MBA-2205) Co-Authored-By: Humza Rabbani <humza.rabbani@cognition.ai>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MBA-2205 / TICKET-04. Adds a Snowflake dbt model that replaces
bteq/02_stg_txn_summary.bteq; the Teradata/SAS assets are left in place and untouched.New:
dbt/models/staging/stg_txn_summary.sql(+ sources, tests,log_etl_runmacro, reconciliation analysis) anddocs/modernization/TICKET-04_stg_txn_summary.md.Mapping decisions (full table in the doc):
CREATE VOLATILE TABLE VT_RUN_PARAMS+${LOOKBACK_MONTHS}shell substitutionrun_paramsCTE off thelookback_monthsdbt var —dbt run --vars '{lookback_months: 24}'changes the window with no code editADD_MONTHS(CURRENT_DATE, -n)/CURRENT_DATE - MAX(d)/NULLIFZERO(x)/CURRENT_TIMESTAMP(6)DATEADD(month, -n, CURRENT_DATE)/DATEDIFF(day, MAX(d), PERIOD_END)/NULLIF(x, 0)/CURRENT_TIMESTAMP()DECIMAL(18,2),DECIMAL(5,2)NUMBER(18,2),NUMBER(5,2)DROP+CREATE MULTISET TABLE ... WITH DATA PRIMARY INDEX (CUSTOMER_ID, ACCOUNT_ID)materialized='table',cluster_by=['CUSTOMER_ID','ACCOUNT_ID']COLLECT STATISTICS.IF ERRORCODE <> 0 THEN .EXIT.IF ACTIVITYCOUNT = 0 THEN .EXIT 99assert_stg_txn_summary_not_empty(post-hook also logsZERO_ROWS)INSERT INTO ETL_RUN_LOG ...post_hook="{{ log_etl_run('02_stg_txn_summary') }}"Three behavioural deltas, all required by the acceptance criteria:
ACCOUNT_IDand then grouped bytop_cat.MERCHANT_CATEGORY, which can emit multiple rows per account. The model resolves one top category per account (ties broken alphabetically) before joining, so the grain is one row perACCOUNT_ID— what the target DDL's primary index implies and what the uniqueness test asserts.PCT_OTHER_CHANNELadded.CHANNEL_CODEalso carriesACH/WIRE, so the four legacy percentages did not sum to 100. With the extra bucket the mix totals 100 per account (asserted within 0.05 rounding tolerance).TXN_COUNT_REVENUE,AMT_TOTAL_REVENUEfromTRANSACTION_TYPES.IS_REVENUE.config/pipeline_config.cfgnow derivesDBT_VARSfrom the existingLOOKBACK_MONTHS;ddl/01_staging_tables.sqlgets a pointer comment on theSTG_TXN_SUMMARYblock (Teradata DDL unchanged).Assumptions about unmerged predecessors
CORE_BANKING.ACCOUNTS,TXN_PROCESSING.TRANSACTIONS,TXN_PROCESSING.TRANSACTION_TYPESin databaseSNOWFLAKE_DATABASE(defaultRETAIL_BANKING), with column names preserved from the Teradata DDL. Only the source YAMLs need editing if TICKET-01 lands different names.ETL_RUN_LOGis assumed to keep its(JOB_NAME, STEP_NAME, STATUS, ROW_COUNT, START_TS, END_TS)shape in schemavar('etl_staging_schema').retail_banking_analyticsdbt profile from TICKET-02.dbt_project.yml, source YAMLs,log_etl_run) is added here because TICKET-03 is not merged; if it lands the same files, keep one copy — the model itself is unaffected.Validation
No warehouse available, so static only:
dbt parsesucceeds (1 model, 1 analysis, 9 tests, 3 sources), andsqlfluff parsewithdialect = snowflakeis clean for the model, all three singular tests and the analysis (dbt/.sqlfluffadded so this is reproducible offline).analyses/recon_stg_txn_summary.sqlcompares row counts and per-column sums against the legacy output landed asLEGACY_STG_TXN_SUMMARYfor the same window.Devin-Org: engineering
Link to Devin session: https://app.devin.ai/sessions/125e1a3f81694bfda7efc5c5b59d2dce
Requested by: @hrabbani
Devin Review