Sybase IQ to dbt Model Conversion
Purpose
Transform Sybase IQ 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 Sybase IQ views or tables to dbt models
- Migrating Sybase stored procedures to dbt
- Translating Sybase SQL syntax to Snowflake
- Generating schema.yml files with tests and documentation
- Handling Sybase-specific syntax conversions (T-SQL variant, built-in functions)
Task Description
You are a database engineer working for a hospital system. You need to convert Sybase IQ 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 Sybase 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: [database].[owner].[object_name]
Source Platform: Sybase IQ
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,
-- MONEY converted to NUMBER(18,2)
account_balance::NUMBER(18,2) AS account_balance,
-- DATETIME converted to TIMESTAMP_NTZ
created_date::TIMESTAMP_NTZ 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 Sybase IQ [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
Sybase to Snowflake Syntax Conversion
- Convert T-SQL variant syntax to Snowflake
- Replace Sybase built-in functions with Snowflake equivalents
- Handle SELECT statement differences
- Convert data types specific to Sybase IQ
- Replace procedural code with Snowflake Scripting
- Handle CASE expression differences
- Convert string functions
Key Data Type Mappings
| Sybase IQ |
Snowflake |
Notes |
| INT/INTEGER |
INTEGER |
|
| BIGINT |
BIGINT |
|
| SMALLINT/TINYINT |
Same |
|
| DECIMAL/NUMERIC |
Same |
|
| FLOAT/REAL/DOUBLE |
FLOAT |
|
| CHAR/VARCHAR |
Same |
|
| TEXT |
VARCHAR |
|
| BINARY/VARBINARY |
BINARY |
|
| BIT |
BOOLEAN |
|
| DATE |
DATE |
|
| TIME |
TIME |
|
| DATETIME/TIMESTAMP |
TIMESTAMP |
|
| MONEY/SMALLMONEY |
NUMBER(38,4) |
|
Key Syntax Conversions
-- TOP -> LIMIT
SELECT TOP 10 * FROM table -> SELECT * FROM table LIMIT 10
-- GETDATE() -> CURRENT_TIMESTAMP
GETDATE() -> CURRENT_TIMESTAMP()
-- ISNULL -> COALESCE
ISNULL(col, 0) -> COALESCE(col, 0)
-- CONVERT -> :: casting or TO_* functions
CONVERT(VARCHAR, col) -> col::VARCHAR
CONVERT(VARCHAR(50), col) -> col::VARCHAR(50)
CONVERT(DATE, col, 101) -> TO_DATE(col, 'MM/DD/YYYY')
-- String functions
CHARINDEX('x', col) -> POSITION('x' IN col)
Common Function Mappings
| Sybase IQ |
Snowflake |
Notes |
ISNULL(a, b) |
COALESCE(a, b) or IFNULL(a, b) |
|
COALESCE(...) |
COALESCE(...) |
Same |
NULLIF(a, b) |
NULLIF(a, b) |
Same |
GETDATE() |
CURRENT_TIMESTAMP() |
|
DATEADD(unit, n, d) |
DATEADD(unit, n, d) |
Same |
DATEDIFF(unit, d1, d2) |
DATEDIFF(unit, d1, d2) |
Same |
DATEPART(unit, d) |
DATE_PART(unit, d) |
|
CONVERT(type, val) |
val::type |
|
CAST(val AS type) |
val::type |
|
CHARINDEX(s, str) |
POSITION(s IN str) |
|
SUBSTRING(s, pos, len) |
SUBSTR(s, pos, len) |
|
LEN(str) |
LENGTH(str) |
|
REPLICATE(str, n) |
REPEAT(str, n) |
|
STUFF(s, pos, len, new) |
INSERT(s, pos, len, new) |
|
ROUND(n, d) |
ROUND(n, d) |
Same |
CEILING(n) |
CEIL(n) |
|
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
- [] Sybase-specific syntax converted (T-SQL variant functions, SELECT differences)
- [] 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 |
| Sybase IQ |
T-SQL variant, different built-in functions, SELECT syntax differences |
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
- Built In Functions
- Create Table
- Create View
- Data Types
- Overview (README)
- Select Statement
- Subqueries
1---2name: dbt-migration-sybase3description: Convert Sybase IQ DDL to dbt models compatible with Snowflake. This skill should be used when converting views, tables, or stored procedures from Sybase IQ to dbt code, generating schema.yml files with tests and documentation, or migrating Sybase SQL to follow dbt best practices.4---5
6# Sybase IQ to dbt Model Conversion
7
8## Purpose
9
10Transform Sybase IQ 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 Sybase IQ views or tables to dbt models
19- Migrating Sybase stored procedures to dbt
20- Translating Sybase SQL syntax to Snowflake
21- Generating schema.yml files with tests and documentation
22- Handling Sybase-specific syntax conversions (T-SQL variant, built-in functions)
23
24---
25
26## Task Description
27
28You are a database engineer working for a hospital system. You need to convert Sybase IQ 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 Sybase 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: [database].[owner].[object_name]
67 Source Platform: Sybase IQ
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 -- MONEY converted to NUMBER(18,2)
77 account_balance::NUMBER(18,2) AS account_balance,
78 -- DATETIME converted to TIMESTAMP_NTZ
79 created_date::TIMESTAMP_NTZ AS created_date
80 FROM {{ ref('upstream_model') }}
81),
82
83transformed_data AS (
84 SELECT
85 customer_id,
86 UPPER(customer_name)::VARCHAR(100) AS customer_name_upper,
87 account_balance,
88 created_date,
89 CURRENT_TIMESTAMP()::TIMESTAMP_NTZ AS loaded_at
90 FROM source_data
91)
92
93SELECT
94 customer_id,
95 customer_name_upper,
96 account_balance,
97 created_date,
98 loaded_at
99FROM transformed_data
100```
101
102```yaml
103## models/[domain]/[target_schema_name]/_models.yml
104version: 2
105
106models:
107 - name: model_name
108 description: "Table description; converted from Sybase IQ [Original object name]"
109 columns:
110 - name: customer_id
111 description: "Primary key - unique customer identifier"
112 tests:
113 - unique
114 - not_null
115 - name: customer_name_upper
116 description: "Customer name in uppercase"
117 - name: account_balance
118 description: "Current account balance; Foreign key to OTHER_TABLE"
119 tests:
120 - relationships:
121 to: ref('OTHER_TABLE')
122 field: OTHER_TABLE_KEY
123 - name: created_date
124 description: "Date the customer record was created"
125 - name: loaded_at
126 description: "Timestamp when the record was loaded by dbt"
127```
128
129```yaml
130## dbt_project.yml (excerpt)
131models:
132 my_project:
133 +materialized: view
134 domain_name:
135 +schema: target_schema_name
136```
137
138### Specific Translation Rules
139
140#### dbt Specific Requirements
141
142- If the source is a view, use a view materialization in dbt
143- Include appropriate dbt model configuration (materialization type)
144- Add documentation blocks for a schema.yml
145- Add descriptions for tables and columns
146- Include relevant tests
147- Define primary keys and relationships
148- Assume that upstream objects are models
149- Comprehensively provide all the columns in the output
150- Break complex procedures into multiple models if needed
151- Implement appropriate incremental strategies for large tables
152- Use Snowflake SQL functions rather than macros whenever possible
153- **Always cast columns with explicit precision/scale** using `::TYPE` syntax (e.g.,
154 `column_name::VARCHAR(100)`, `amount::NUMBER(18,2)`) to ensure output matches expected data types
155- **Always provide explicit column aliases** for clarity and documentation
156
157#### Performance Optimization
158
159- Suggest clustering keys if needed
160- Recommend materialization strategy (view vs table)
161- Identify potential performance improvements
162
163#### Sybase to Snowflake Syntax Conversion
164
165- Convert T-SQL variant syntax to Snowflake
166- Replace Sybase built-in functions with Snowflake equivalents
167- Handle SELECT statement differences
168- Convert data types specific to Sybase IQ
169- Replace procedural code with Snowflake Scripting
170- Handle CASE expression differences
171- Convert string functions
172
173#### Key Data Type Mappings
174
175| Sybase IQ | Snowflake | Notes |
176| ------------------ | ------------ | ----- |
177| INT/INTEGER | INTEGER | |
178| BIGINT | BIGINT | |
179| SMALLINT/TINYINT | Same | |
180| DECIMAL/NUMERIC | Same | |
181| FLOAT/REAL/DOUBLE | FLOAT | |
182| CHAR/VARCHAR | Same | |
183| TEXT | VARCHAR | |
184| BINARY/VARBINARY | BINARY | |
185| BIT | BOOLEAN | |
186| DATE | DATE | |
187| TIME | TIME | |
188| DATETIME/TIMESTAMP | TIMESTAMP | |
189| MONEY/SMALLMONEY | NUMBER(38,4) | |
190
191#### Key Syntax Conversions
192
193```sql
194-- TOP -> LIMIT
195SELECT TOP 10 * FROM table -> SELECT * FROM table LIMIT 10
196
197-- GETDATE() -> CURRENT_TIMESTAMP
198GETDATE() -> CURRENT_TIMESTAMP()
199
200-- ISNULL -> COALESCE
201ISNULL(col, 0) -> COALESCE(col, 0)
202
203-- CONVERT -> :: casting or TO_* functions
204CONVERT(VARCHAR, col) -> col::VARCHAR
205CONVERT(VARCHAR(50), col) -> col::VARCHAR(50)
206CONVERT(DATE, col, 101) -> TO_DATE(col, 'MM/DD/YYYY')
207
208-- String functions
209CHARINDEX('x', col) -> POSITION('x' IN col)
210```
211
212#### Common Function Mappings
213
214| Sybase IQ | Snowflake | Notes |
215| ------------------------- | ---------------------------------- | ----- |
216| `ISNULL(a, b)` | `COALESCE(a, b)` or `IFNULL(a, b)` | |
217| `COALESCE(...)` | `COALESCE(...)` | Same |
218| `NULLIF(a, b)` | `NULLIF(a, b)` | Same |
219| `GETDATE()` | `CURRENT_TIMESTAMP()` | |
220| `DATEADD(unit, n, d)` | `DATEADD(unit, n, d)` | Same |
221| `DATEDIFF(unit, d1, d2)` | `DATEDIFF(unit, d1, d2)` | Same |
222| `DATEPART(unit, d)` | `DATE_PART(unit, d)` | |
223| `CONVERT(type, val)` | `val::type` | |
224| `CAST(val AS type)` | `val::type` | |
225| `CHARINDEX(s, str)` | `POSITION(s IN str)` | |
226| `SUBSTRING(s, pos, len)` | `SUBSTR(s, pos, len)` | |
227| `LEN(str)` | `LENGTH(str)` | |
228| `REPLICATE(str, n)` | `REPEAT(str, n)` | |
229| `STUFF(s, pos, len, new)` | `INSERT(s, pos, len, new)` | |
230| `ROUND(n, d)` | `ROUND(n, d)` | Same |
231| `CEILING(n)` | `CEIL(n)` | |
232
233#### Dependencies
234
235- List any upstream dependencies
236- Suggest model organization in dbt project
237
238---
239
240## Validation Checklist
241
242- [] Every DDL statement has been accounted for in the dbt models
243- [] SQL in models is compatible with Snowflake
244- [] Sybase-specific syntax converted (T-SQL variant functions, SELECT differences)
245- [] All business logic preserved
246- [] All columns included in output
247- [] Data types correctly mapped
248- [] Functions translated to Snowflake equivalents
249- [] Materialization strategy selected
250- [] Tests added
251- [] SQL logic description complete
252- [] Table descriptions added
253- [] Column descriptions added
254- [] Dependencies correctly mapped
255- [] Incremental logic (if applicable) verified
256- [] Inline comments added for converted syntax
257
258---
259
260## Related Skills
261
262- $dbt-migration - For the complete migration workflow (discovery, planning, placeholder models,
263 testing, deployment)
264- $dbt-modeling - For CTE patterns and SQL structure guidance
265- $dbt-testing - For implementing comprehensive dbt tests
266- $dbt-architecture - For project organization and folder structure
267- $dbt-materializations - For choosing materialization strategies (view, table, incremental,
268 snapshots)
269- $dbt-performance - For clustering keys, warehouse sizing, and query optimization
270- $dbt-commands - For running dbt commands and model selection syntax
271- $dbt-core - For dbt installation, configuration, and package management
272- $snowflake-cli - For executing SQL and managing Snowflake objects
273
274---
275
276## Supported Source Database
277
278| Database | Key Considerations |
279| ------------- | ---------------------------------------------------------------------- |
280| **Sybase IQ** | T-SQL variant, different built-in functions, SELECT syntax differences |
281
282## Translation References
283
284Detailed syntax translation guides are available in the `translation-references/` folder.
285
286> **Copyright Notice:** The translation reference documentation in this repository is derived from
287> [Snowflake SnowConvert Documentation](https://docs.snowflake.com/en/migrations/snowconvert-docs)
288> and is © Copyright Snowflake Inc. All rights reserved. Used for reference purposes only.
289
290### Reference Index
291
292- [Built In Functions](translation-references/sybase-built-in-functions.md)
293- [Create Table](translation-references/sybase-create-table.md)
294- [Create View](translation-references/sybase-create-view.md)
295- [Data Types](translation-references/sybase-data-types.md)
296- [Overview (README)](translation-references/sybase-readme.md)
297- [Select Statement](translation-references/sybase-select-statement.md)
298- [Subqueries](translation-references/sybase-subqueries.md)