Vertica to dbt Model Conversion
Purpose
Transform Vertica 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.
When to Use This Skill
Activate this skill when users ask about:
- Converting Vertica views or tables to dbt models
- Migrating Vertica stored procedures to dbt
- Translating Vertica SQL syntax to Snowflake
- Generating schema.yml files with tests and documentation
- Handling Vertica-specific syntax (projections, flex tables, ANY/ALL predicates)
Task Description
You are a database engineer working for a hospital system. You need to convert Vertica DDL to
equivalent dbt code compatible with Snowflake, maintaining the same business logic and data
transformation steps while following dbt best practices.
Input Requirements
I will provide you the Vertica DDL to convert.
Audience
The code will be executed by data engineers who are learning Snowflake and dbt.
Output Requirements
Generate the following:
- One or more dbt models with complete SQL for every column
- A corresponding schema.yml file with appropriate tests and documentation
- A config block with materialization strategy
- Explanation of key changes and architectural decisions
- Inline comments highlighting any syntax that was converted
Conversion Guidelines
General Principles
- Replace procedural logic with declarative SQL where possible
- Break down complex procedures into multiple modular dbt models
- Implement appropriate incremental processing strategies
- Maintain data quality checks through dbt tests
- Use Snowflake SQL functions rather than macros whenever possible
Sample Response Format
-- dbt model: models/[domain]/[target_schema_name]/model_name.sql
{{ config(materialized='view') }}
/* Original Object: [schema].[object_name]
Source Platform: Vertica
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,
-- TIMESTAMPTZ converted to TIMESTAMP_TZ
created_date::TIMESTAMP_TZ 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 Vertica [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
Specific Translation Rules
dbt Specific Requirements
- If the source is a view, use a view materialization in dbt
- Include appropriate dbt model configuration (materialization type)
- Add documentation blocks for a schema.yml
- Add descriptions for tables and columns
- Include relevant tests
- Define primary keys and relationships
- Assume that upstream objects are models
- Comprehensively provide all the columns in the output
- Break complex procedures into multiple models if needed
- Implement appropriate incremental strategies for large tables
- Use Snowflake SQL functions rather than macros whenever possible
- Always cast columns with explicit precision/scale using
::TYPE syntax (e.g.,
column_name::VARCHAR(100), amount::NUMBER(18,2)) to ensure output matches expected data types
- Always provide explicit column aliases for clarity and documentation
Performance Optimization
- Suggest clustering keys if needed
- Recommend materialization strategy (view vs table)
- Identify potential performance improvements
Vertica to Snowflake Syntax Conversion
- Remove projection specifications
- Handle flex table conversions
- Convert case sensitivity with quoted identifiers
- Replace ANY/ALL array predicates with Snowflake equivalents
- Convert Vertica-specific functions
- Handle COPY syntax differences
- Remove SEGMENTED BY clauses
Key Data Type Mappings
| Vertica |
Snowflake |
Notes |
| INT/INTEGER/BIGINT/SMALLINT/TINYINT |
Same |
|
| NUMERIC/DECIMAL |
Same |
|
| FLOAT/REAL/DOUBLE PRECISION |
FLOAT |
|
| CHAR/VARCHAR |
Same |
|
| LONG VARCHAR |
VARCHAR |
|
| BINARY/VARBINARY/LONG VARBINARY |
BINARY |
|
| BOOLEAN |
BOOLEAN |
|
| DATE |
DATE |
|
| TIME/TIMETZ |
TIME |
|
| TIMESTAMP/TIMESTAMPTZ |
TIMESTAMP/TIMESTAMP_TZ |
|
| INTERVAL |
VARCHAR |
|
| UUID |
VARCHAR |
|
Key Syntax Conversions
-- Projections -> Remove (Snowflake auto-manages)
CREATE PROJECTION proj AS SELECT ... -> (remove entirely)
-- SEGMENTED BY -> CLUSTER BY
CREATE TABLE t (...) SEGMENTED BY HASH(id) ->
CREATE TABLE t (...) CLUSTER BY (id)
-- Flex tables -> VARIANT columns
CREATE FLEX TABLE t() -> CREATE TABLE t (data VARIANT)
-- Case sensitivity (Vertica folds to lowercase)
SELECT Col -> SELECT "Col" -- if case matters
-- ANY/ALL array predicates
col = ANY(ARRAY[1,2,3]) -> col IN (1,2,3)
col <> ALL(ARRAY[1,2,3]) -> col NOT IN (1,2,3)
Common Function Mappings
| Vertica |
Snowflake |
Notes |
NVL(a, b) |
NVL(a, b) |
Same |
NVL2(a, b, c) |
IFF(a IS NOT NULL, b, c) |
|
COALESCE(...) |
COALESCE(...) |
Same |
NULLIF(a, b) |
NULLIF(a, b) |
Same |
DECODE(expr, ...) |
CASE expr WHEN ... END |
|
GETDATE() |
CURRENT_TIMESTAMP() |
|
SYSDATE |
CURRENT_TIMESTAMP() |
|
ADD_MONTHS(d, n) |
DATEADD('month', n, d) |
|
DATEDIFF(unit, d1, d2) |
DATEDIFF(unit, d1, d2) |
Same |
TO_CHAR(d, fmt) |
TO_CHAR(d, fmt) |
Same |
TO_DATE(s, fmt) |
TO_DATE(s, fmt) |
Same |
INSTR(str, search) |
POSITION(search IN str) |
|
SUBSTR(s, pos, len) |
SUBSTR(s, pos, len) |
Same |
REGEXP_LIKE(s, p) |
REGEXP_LIKE(s, p) |
Same |
LISTAGG(col, delim) |
LISTAGG(col, delim) |
Same |
SPLIT_PART(s, d, n) |
SPLIT_PART(s, d, n) |
Same |
Dependencies
- List any upstream dependencies
- Suggest model organization in dbt project
Validation Checklist
- [] Every DDL statement has been accounted for in the dbt models
- [] SQL in models is compatible with Snowflake
- [] Vertica-specific syntax converted (projections removed, case sensitivity handled)
- [] All business logic preserved
- [] All columns included in output
- [] Data types correctly mapped
- [] Functions translated to Snowflake equivalents
- [] Materialization strategy selected
- [] Tests added
- [] SQL logic description complete
- [] Table descriptions added
- [] Column descriptions added
- [] Dependencies correctly mapped
- [] Incremental logic (if applicable) verified
- [] Inline comments added for converted syntax
Related Skills
- $dbt-migration - For the complete migration workflow (discovery, planning, placeholder models,
testing, deployment)
- $dbt-modeling - For CTE patterns and SQL structure guidance
- $dbt-testing - For implementing comprehensive dbt tests
- $dbt-architecture - For project organization and folder structure
- $dbt-materializations - For choosing materialization strategies (view, table, incremental,
snapshots)
- $dbt-performance - For clustering keys, warehouse sizing, and query optimization
- $dbt-commands - For running dbt commands and model selection syntax
- $dbt-core - For dbt installation, configuration, and package management
- $snowflake-cli - For executing SQL and managing Snowflake objects
Supported Source Database
| Database |
Key Considerations |
| Vertica |
Projections, flex tables, case sensitivity with quotes, ANY/ALL array predicates |
Translation References
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.
Reference Index
- Create Table
- Create View
- Data Types
- Identifier Between Vertica And Snowflake
- Operators
- Predicates
- Overview (README)
- Subqueries
1---2name: dbt-migration-vertica3description: Convert Vertica DDL to dbt models compatible with Snowflake. This skill should be used when converting views, tables, or stored procedures from Vertica to dbt code, generating schema.yml files with tests and documentation, or migrating Vertica SQL to follow dbt best practices.4---5
6# Vertica to dbt Model Conversion
7
8## Purpose
9
10Transform Vertica DDL (views, tables, stored procedures) into production-quality dbt models
11compatible with Snowflake, maintaining the same business logic and data transformation steps while
12following dbt best practices.
13
14## When to Use This Skill
15
16Activate this skill when users ask about:
17
18- Converting Vertica views or tables to dbt models
19- Migrating Vertica stored procedures to dbt
20- Translating Vertica SQL syntax to Snowflake
21- Generating schema.yml files with tests and documentation
22- Handling Vertica-specific syntax (projections, flex tables, ANY/ALL predicates)
23
24---
25
26## Task Description
27
28You are a database engineer working for a hospital system. You need to convert Vertica DDL to
29equivalent dbt code compatible with Snowflake, maintaining the same business logic and data
30transformation steps while following dbt best practices.
31
32## Input Requirements
33
34I will provide you the Vertica DDL to convert.
35
36## Audience
37
38The code will be executed by data engineers who are learning Snowflake and dbt.
39
40## Output Requirements
41
42Generate the following:
43
441. One or more dbt models with complete SQL for every column
452. A corresponding schema.yml file with appropriate tests and documentation
463. A config block with materialization strategy
474. Explanation of key changes and architectural decisions
485. Inline comments highlighting any syntax that was converted
49
50## Conversion Guidelines
51
52### General Principles
53
54- Replace procedural logic with declarative SQL where possible
55- Break down complex procedures into multiple modular dbt models
56- Implement appropriate incremental processing strategies
57- Maintain data quality checks through dbt tests
58- Use Snowflake SQL functions rather than macros whenever possible
59
60### Sample Response Format
61
62```sql
63-- dbt model: models/[domain]/[target_schema_name]/model_name.sql
64{{ config(materialized='view') }}
65
66/* Original Object: [schema].[object_name]
67 Source Platform: Vertica
68 Purpose: [brief description]
69 Conversion Notes: [key changes]
70 Description: [SQL logic description] */
71
72WITH source_data AS (
73 SELECT
74 customer_id::INTEGER AS customer_id,
75 customer_name::VARCHAR(100) AS customer_name,
76 account_balance::NUMBER(18,2) AS account_balance,
77 -- TIMESTAMPTZ converted to TIMESTAMP_TZ
78 created_date::TIMESTAMP_TZ AS created_date
79 FROM {{ ref('upstream_model') }}
80),
81
82transformed_data AS (
83 SELECT
84 customer_id,
85 UPPER(customer_name)::VARCHAR(100) AS customer_name_upper,
86 account_balance,
87 created_date,
88 CURRENT_TIMESTAMP()::TIMESTAMP_NTZ AS loaded_at
89 FROM source_data
90)
91
92SELECT
93 customer_id,
94 customer_name_upper,
95 account_balance,
96 created_date,
97 loaded_at
98FROM transformed_data
99```
100
101```yaml
102## models/[domain]/[target_schema_name]/_models.yml
103version: 2
104
105models:
106 - name: model_name
107 description: "Table description; converted from Vertica [Original object name]"
108 columns:
109 - name: customer_id
110 description: "Primary key - unique customer identifier"
111 tests:
112 - unique
113 - not_null
114 - name: customer_name_upper
115 description: "Customer name in uppercase"
116 - name: account_balance
117 description: "Current account balance; Foreign key to OTHER_TABLE"
118 tests:
119 - relationships:
120 to: ref('OTHER_TABLE')
121 field: OTHER_TABLE_KEY
122 - name: created_date
123 description: "Date the customer record was created"
124 - name: loaded_at
125 description: "Timestamp when the record was loaded by dbt"
126```
127
128```yaml
129## dbt_project.yml (excerpt)
130models:
131 my_project:
132 +materialized: view
133 domain_name:
134 +schema: target_schema_name
135```
136
137### Specific Translation Rules
138
139#### dbt Specific Requirements
140
141- If the source is a view, use a view materialization in dbt
142- Include appropriate dbt model configuration (materialization type)
143- Add documentation blocks for a schema.yml
144- Add descriptions for tables and columns
145- Include relevant tests
146- Define primary keys and relationships
147- Assume that upstream objects are models
148- Comprehensively provide all the columns in the output
149- Break complex procedures into multiple models if needed
150- Implement appropriate incremental strategies for large tables
151- Use Snowflake SQL functions rather than macros whenever possible
152- **Always cast columns with explicit precision/scale** using `::TYPE` syntax (e.g.,
153 `column_name::VARCHAR(100)`, `amount::NUMBER(18,2)`) to ensure output matches expected data types
154- **Always provide explicit column aliases** for clarity and documentation
155
156#### Performance Optimization
157
158- Suggest clustering keys if needed
159- Recommend materialization strategy (view vs table)
160- Identify potential performance improvements
161
162#### Vertica to Snowflake Syntax Conversion
163
164- Remove projection specifications
165- Handle flex table conversions
166- Convert case sensitivity with quoted identifiers
167- Replace ANY/ALL array predicates with Snowflake equivalents
168- Convert Vertica-specific functions
169- Handle COPY syntax differences
170- Remove SEGMENTED BY clauses
171
172#### Key Data Type Mappings
173
174| Vertica | Snowflake | Notes |
175| ----------------------------------- | ---------------------- | ----- |
176| INT/INTEGER/BIGINT/SMALLINT/TINYINT | Same | |
177| NUMERIC/DECIMAL | Same | |
178| FLOAT/REAL/DOUBLE PRECISION | FLOAT | |
179| CHAR/VARCHAR | Same | |
180| LONG VARCHAR | VARCHAR | |
181| BINARY/VARBINARY/LONG VARBINARY | BINARY | |
182| BOOLEAN | BOOLEAN | |
183| DATE | DATE | |
184| TIME/TIMETZ | TIME | |
185| TIMESTAMP/TIMESTAMPTZ | TIMESTAMP/TIMESTAMP_TZ | |
186| INTERVAL | VARCHAR | |
187| UUID | VARCHAR | |
188
189#### Key Syntax Conversions
190
191```sql
192-- Projections -> Remove (Snowflake auto-manages)
193CREATE PROJECTION proj AS SELECT ... -> (remove entirely)
194
195-- SEGMENTED BY -> CLUSTER BY
196CREATE TABLE t (...) SEGMENTED BY HASH(id) ->
197CREATE TABLE t (...) CLUSTER BY (id)
198
199-- Flex tables -> VARIANT columns
200CREATE FLEX TABLE t() -> CREATE TABLE t (data VARIANT)
201
202-- Case sensitivity (Vertica folds to lowercase)
203SELECT Col -> SELECT "Col" -- if case matters
204
205-- ANY/ALL array predicates
206col = ANY(ARRAY[1,2,3]) -> col IN (1,2,3)
207col <> ALL(ARRAY[1,2,3]) -> col NOT IN (1,2,3)
208```
209
210#### Common Function Mappings
211
212| Vertica | Snowflake | Notes |
213| ------------------------ | -------------------------- | ----- |
214| `NVL(a, b)` | `NVL(a, b)` | Same |
215| `NVL2(a, b, c)` | `IFF(a IS NOT NULL, b, c)` | |
216| `COALESCE(...)` | `COALESCE(...)` | Same |
217| `NULLIF(a, b)` | `NULLIF(a, b)` | Same |
218| `DECODE(expr, ...)` | `CASE expr WHEN ... END` | |
219| `GETDATE()` | `CURRENT_TIMESTAMP()` | |
220| `SYSDATE` | `CURRENT_TIMESTAMP()` | |
221| `ADD_MONTHS(d, n)` | `DATEADD('month', n, d)` | |
222| `DATEDIFF(unit, d1, d2)` | `DATEDIFF(unit, d1, d2)` | Same |
223| `TO_CHAR(d, fmt)` | `TO_CHAR(d, fmt)` | Same |
224| `TO_DATE(s, fmt)` | `TO_DATE(s, fmt)` | Same |
225| `INSTR(str, search)` | `POSITION(search IN str)` | |
226| `SUBSTR(s, pos, len)` | `SUBSTR(s, pos, len)` | Same |
227| `REGEXP_LIKE(s, p)` | `REGEXP_LIKE(s, p)` | Same |
228| `LISTAGG(col, delim)` | `LISTAGG(col, delim)` | Same |
229| `SPLIT_PART(s, d, n)` | `SPLIT_PART(s, d, n)` | Same |
230
231#### Dependencies
232
233- List any upstream dependencies
234- Suggest model organization in dbt project
235
236---
237
238## Validation Checklist
239
240- [] Every DDL statement has been accounted for in the dbt models
241- [] SQL in models is compatible with Snowflake
242- [] Vertica-specific syntax converted (projections removed, case sensitivity handled)
243- [] All business logic preserved
244- [] All columns included in output
245- [] Data types correctly mapped
246- [] Functions translated to Snowflake equivalents
247- [] Materialization strategy selected
248- [] Tests added
249- [] SQL logic description complete
250- [] Table descriptions added
251- [] Column descriptions added
252- [] Dependencies correctly mapped
253- [] Incremental logic (if applicable) verified
254- [] Inline comments added for converted syntax
255
256---
257
258## Related Skills
259
260- $dbt-migration - For the complete migration workflow (discovery, planning, placeholder models,
261 testing, deployment)
262- $dbt-modeling - For CTE patterns and SQL structure guidance
263- $dbt-testing - For implementing comprehensive dbt tests
264- $dbt-architecture - For project organization and folder structure
265- $dbt-materializations - For choosing materialization strategies (view, table, incremental,
266 snapshots)
267- $dbt-performance - For clustering keys, warehouse sizing, and query optimization
268- $dbt-commands - For running dbt commands and model selection syntax
269- $dbt-core - For dbt installation, configuration, and package management
270- $snowflake-cli - For executing SQL and managing Snowflake objects
271
272---
273
274## Supported Source Database
275
276| Database | Key Considerations |
277| ----------- | -------------------------------------------------------------------------------- |
278| **Vertica** | Projections, flex tables, case sensitivity with quotes, ANY/ALL array predicates |
279
280## Translation References
281
282Detailed syntax translation guides are available in the `translation-references/` folder.
283
284> **Copyright Notice:** The translation reference documentation in this repository is derived from
285> [Snowflake SnowConvert Documentation](https://docs.snowflake.com/en/migrations/snowconvert-docs)
286> and is © Copyright Snowflake Inc. All rights reserved. Used for reference purposes only.
287
288### Reference Index
289
290- [Create Table](translation-references/vertica-create-table.md)
291- [Create View](translation-references/vertica-create-view.md)
292- [Data Types](translation-references/vertica-data-types.md)
293- [Identifier Between Vertica And Snowflake](translation-references/vertica-identifier-between-vertica-and-snowflake.md)
294- [Operators](translation-references/vertica-operators.md)
295- [Predicates](translation-references/vertica-predicates.md)
296- [Overview (README)](translation-references/vertica-readme.md)
297- [Subqueries](translation-references/vertica-subqueries.md)