Skip to content

[MBA-2202] Snowflake DDL migration for source, staging and data product tables - #76

Open
hrabbani wants to merge 1 commit into
mainfrom
devin/1787357370-mba-2202-snowflake-ddl
Open

hrabbani wants to merge 1 commit into
mainfrom
devin/1787357370-mba-2202-snowflake-ddl

Conversation

@hrabbani

@hrabbani hrabbani commented Aug 22, 2026

Copy link
Copy Markdown

Summary

Adds a Snowflake translation of all 12 Teradata tables under a new ddl/snowflake/ directory. The Teradata scripts (ddl/00_source_tables.sql, ddl/01_staging_tables.sql, ddl/02_data_product_tables.sql) are left untouched as the migration reference; nothing else in the repo is modified.

Layout: Teradata databases become schemas inside one database per environment, with <ENV> supplied as a SnowSQL variable (snowsql -f ... -D env=DEV):

CORE_BANKING_DB    -> RETAIL_BANKING_&{env}.CORE_BANKING
TXN_PROCESSING_DB  -> RETAIL_BANKING_&{env}.TXN_PROCESSING
ETL_STAGING_DB     -> RETAIL_BANKING_&{env}.ETL_STAGING
DATA_PRODUCTS_DB   -> RETAIL_BANKING_&{env}.DATA_PRODUCTS

Every statement is CREATE ... IF NOT EXISTS, so the scripts are idempotent and re-runnable in DEV/UAT/PROD without dropping data (CREATE OR REPLACE was deliberately avoided on tables that hold operational/certified data).

Construct mapping (full tables in ddl/snowflake/README.md):

Teradata Snowflake
MULTISET, NO FALLBACK, PRIMARY INDEX, COLLECT STATISTICS, CHARACTER SET LATIN NOT CASESPECIFIC, FORMAT 'YYYY-MM-DD' removed (no Snowflake equivalent / handled automatically)
UNIQUE PRIMARY INDEX (TRANSACTION_TYPE_CD) unenforced PRIMARY KEY constraint, to keep the uniqueness contract in the catalogue
PARTITION BY RANGE_N(TRANSACTION_DATE ... EACH INTERVAL '1' MONTH) CLUSTER BY (TRANSACTION_DATE) on TRANSACTIONS
PARTITION BY COLUMN(REPORTING_PERIOD) CLUSTER BY (REPORTING_PERIOD) on TRANSACTION_ANALYTICS
TIMESTAMP(6) / DECIMAL(p,s) / CHAR(n) / DATE TIMESTAMP_NTZ(6) / NUMBER(p,s) / VARCHAR(n) / DATE
BIGINT / INTEGER / SMALLINT NUMBER(19,0) / NUMBER(10,0) / NUMBER(5,0) (preserves Teradata integer ranges rather than defaulting to NUMBER(38,0))

No other table gets a clustering key: without a range/period access pattern, automatic micro-partitioning is sufficient and reclustering has ongoing cost.

Validation

  • All 4 scripts parse cleanly with sqlglot in the snowflake dialect (after resolving the &{env} substitution).
  • Automated column-parity check: all 12 tables present, with identical column names and order to the Teradata DDL.
  • Keyword scan: no MULTISET, NO FALLBACK, PRIMARY INDEX, COLLECT STATISTICS, CASESPECIFIC or RANGE_N in executable SQL (they appear only in explanatory comments describing what was replaced).
  • Not executed against a live Snowflake account — no credentials available in this session.

Assumptions

  • Warehouses, roles and grants are provisioned by TICKET-02 and are intentionally not created here; this ticket only creates the database/schema containers the DDL depends on.
  • ETL_STAGING_DB.ETL_RUN_LOG (referenced by the BTEQ scripts) has no Teradata DDL in the affected files, so it is out of scope for this ticket and left to the ETL migration ticket.
  • Migrated queries must make case-insensitive comparisons explicit (ILIKE / UPPER()), since NOT CASESPECIFIC semantics do not carry over.

Devin-Org: engineering

Link to Devin session: https://app.devin.ai/sessions/cc38310e2ae84f23a9d0b38a2a858aba
Requested by: @hrabbani


Devin Review

Status Commit
⚪ Not started

Run Devin Review

💡 Connect your GitHub account to enable automatic code reviews.

Open in Devin Review (Staging)

@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant