Convert Teradata DDL to dbt models compatible with Snowflake. This skill should be used when converting views, tables, or stored procedures from Teradata to dbt code, generating schema.yml files with tests and documentation, or migrating Teradata SQL to follow dbt best practices.
Transform Teradata DDL (views, tables, stored procedures) into production-quality dbt models compatible with Snowflake, maintaining the same business logic and data transformation steps while following dbt best practices.
Activate this skill when users ask about:
Do NOT begin manual conversion. Teradata has full SnowConvert AI support (tables, views, procedures, functions, BTEQ/MLOAD/TPUMP). Before writing any dbt model by hand:
- Run SnowConvert AI on the source DDL to produce Snowflake-compatible SQL.
- Use the
$dbt-migration-snowflakeskill to convert the SCAI output to dbt models.- Only fall back to this skill's manual translation rules for objects SCAI could not convert (check the conversion report for EWIs).
See the
$dbt-migrationskill for download links and full workflow.
Preserve original object names. The dbt model filename and model name MUST match the original source object name (lowercased, without database prefix). For example,
DBC.PatientVisitsbecomespatient_visits.sql. Do not rename objects during migration unless explicitly requested by the user.
You are a database engineer working for a hospital system. You need to convert Teradata DDL to equivalent dbt code compatible with Snowflake, maintaining the same business logic and data transformation steps while following dbt best practices.
I will provide you the Teradata DDL to convert.
The code will be executed by data engineers who are learning Snowflake and dbt.
Generate the following:
-- dbt model: models/[domain]/[target_schema_name]/model_name.sql
{{ config(materialized='view') }}
/* Original Object: [database].[table_name]
Source Platform: Teradata
Purpose: [brief description]
Conversion Notes: [key changes]
Description: [SQL logic description] */
WITH source_data AS (
SELECT
customer_id::INTEGER AS customer_id,
customer_name::VARCHAR(100) AS customer_name,
account_balance::NUMBER(18,2) AS account_balance,
created_date::DATE AS created_date
FROM {{ ref('upstream_model') }}
),
transformed_data AS (
SELECT
customer_id,
UPPER(customer_name)::VARCHAR(100) AS customer_name_upper,
account_balance,
created_date,
CURRENT_TIMESTAMP()::TIMESTAMP_NTZ AS loaded_at
FROM source_data
)
SELECT
customer_id,
customer_name_upper,
account_balance,
created_date,
loaded_at
FROM transformed_data
## models/[domain]/[target_schema_name]/_models.yml
version: 2
models:
- name: model_name
description: "Table description; converted from Teradata [Original object name]"
columns:
- name: customer_id
description: "Primary key - unique customer identifier"
tests:
- unique
- not_null
- name: customer_name_upper
description: "Customer name in uppercase"
- name: account_balance
description: "Current account balance; Foreign key to OTHER_TABLE"
tests:
- relationships:
to: ref('OTHER_TABLE')
field: OTHER_TABLE_KEY
- name: created_date
description: "Date the customer record was created"
- name: loaded_at
description: "Timestamp when the record was loaded by dbt"
## dbt_project.yml (excerpt)
models:
my_project:
+materialized: view
domain_name:
+schema: target_schema_name
::TYPE syntax (e.g.,
column_name::VARCHAR(100), amount::NUMBER(18,2)) to ensure output matches expected data types| Teradata | Snowflake | Notes | | ------------------------ | -------------- | ---------------------------------- | | BIGINT/INTEGER/SMALLINT | NUMBER(38,0) | All integers map to NUMBER | | BYTEINT | BYTEINT | | | DECIMAL/NUMBER | NUMBER | | | FLOAT/REAL | FLOAT | | | CHAR/VARCHAR | CHAR/VARCHAR | | | DATE | DATE | | | TIME/TIMESTAMP | TIME/TIMESTAMP | | | TIMESTAMP WITH TIME ZONE | TIMESTAMP_TZ | | | BLOB | BINARY | Limited to 8MB | | CLOB | VARCHAR | Limited to 16MB | | JSON/XML | VARIANT | | | INTERVAL types | VARCHAR | Store as string, use in arithmetic | | PERIOD types | VARCHAR | Store as 'start*end' format | | ST_GEOMETRY | GEOGRAPHY | |
-- QUALIFY (Teradata) → Same in Snowflake (natively supported)
SELECT * FROM table QUALIFY ROW_NUMBER() OVER (PARTITION BY col ORDER BY col2) = 1
-- Volatile tables → Temporary tables
CREATE VOLATILE TABLE temp_data AS ... → CREATE TEMPORARY TABLE temp_data AS ...
-- SET/MULTISET → Remove (Snowflake handles duplicates differently)
CREATE SET TABLE → CREATE TABLE
CREATE MULTISET TABLE → CREATE TABLE
-- FALLBACK/JOURNAL → Remove (Snowflake-managed)
NO FALLBACK, NO JOURNAL → (remove entirely)
-- FORMAT in column definition → Remove
DATE FORMAT 'YYYY-MM-DD' → DATE
-- CASESPECIFIC → Remove (use COLLATE if needed)
VARCHAR(100) NOT CASESPECIFIC → VARCHAR(100)
| Teradata | Snowflake | Notes |
| ------------------------ | -------------------------------------------------- | -------------------------------- |
| NVL(a, b) | NVL(a, b) or COALESCE(a, b) | Same |
| NULLIFZERO(col) | NULLIF(col, 0) | |
| ZEROIFNULL(col) | NVL(col, 0) | |
| COALESCE(...) | COALESCE(...) | Same |
| TRIM(col) | TRIM(col) | Remove RTRIM for trailing spaces |
| SUBSTR(s, pos, len) | SUBSTR(s, pos, len) | Same |
| INDEX(str, search) | POSITION(search IN str) | |
| ADD_MONTHS(d, n) | DATEADD('month', n, d) | |
| TRUNC(d) | DATE_TRUNC('day', d) | |
| EXTRACT(part FROM d) | EXTRACT(part FROM d) | Same |
| DATE '2024-01-15' | DATE '2024-01-15' | Same |
| CAST(x AS FORMAT 'Y4') | TO_CHAR(x, 'YYYY') | |
| CASE_N(cond1, cond2) | CASE WHEN cond1 THEN 1 WHEN cond2 THEN 2 ... END | |
| HASHROW(cols) | HASH(cols) | |
| RANDOM(low, high) | UNIFORM(low, high, RANDOM()) | |
| Database | Key Considerations | | ------------ | ----------------------------------------------------------------------------------------------------------- | | Teradata | QUALIFY, ANSI/TERA session modes, volatile tables, SET/MULTISET, BTEQ/FastLoad/MultiLoad scripts, DBC views |
Detailed syntax translation guides are available in the translation-references/ folder.
Copyright Notice: The translation reference documentation in this repository is derived from Snowflake SnowConvert Documentation and is © Copyright Snowflake Inc. All rights reserved. Used for reference purposes only.
npx skills add sfc-gh-dflippo/dbt-migration-teradata下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer