dbt-databricks → dbt-clickzetta Migration in Practice: Financial Payment Data Pipeline
If your data pipeline is built with dbt + Databricks SQL, migrating to Singdata Lakehouse is far less work than you might expect — as little as changing one line in profiles.yml. All core dbt capabilities — CTE models, window functions, SCD Type 2 logic, data quality tests, unit tests, and data contracts — are fully compatible with Lakehouse and require zero changes.
This article validates that claim with a real project: a financial payment data pipeline built on dbt-databricks (staging → intermediate → marts → semantic, 30 models, 36 tests) was fully migrated to dbt-clickzetta and verified with dbt seed 9/9 + dbt run 30/30 + dbt test 36/36 — all passing.
Full code on GitHub: dbt-databricks2lakehouse-blueprint
Original Project
dbt-databricks2lakehouse-blueprint is forked from Alex-Teodosiu/dbt-blueprint (⭐72). The original stack is dbt-databricks + Databricks SQL Warehouse. The project simulates a P2P/P2B (peer-to-peer / peer-to-business) payment platform data engineering pipeline, covering five data domains — users, merchants, accounts, bank cards, and transactions — and implements the complete chain from raw events → cleansing → SCD Type 2 dimension tables → fact tables → semantic layer.
The migrated code is in the 03_lakehouse/ directory and can be compared file-by-file with 01_source/dbt_blueprint/.
Conclusion First
The adapter is dbt's database dialect layer — switching adapters means switching the database; the dbt models themselves do not need to change. Changes are concentrated in profiles.yml (connection configuration) and a handful of Databricks-specific syntax items.
| Change | Files | Effort | Notes |
|---|---|---|---|
| Adapter switch | 1 (profiles.yml) | Minimal | type: databricks → type: clickzetta, different connection params |
| Project profile name | 1 (dbt_project.yml) | Minimal | connection_databricks → dbt_blueprint |
getdate() | 1 | Minimal | → current_date() |
| Macro target name | 1 | Minimal | databricks_cluster → clickzetta_prod |
Parts that need no changes: all CTE model logic, window functions (LEAD/LAG/ROW_NUMBER), SCD Type 2 logic, dbt_utils.generate_surrogate_key(), data quality tests, unit tests, data contracts, SELECT * EXCEPT (col), col :: type cast syntax, DATEDIFF(year, start, end) — all natively supported by Lakehouse.
Technology Stack Comparison
| dbt-databricks (original) | dbt-clickzetta (migrated) | |
|---|---|---|
| dbt adapter | dbt-databricks | dbt-clickzetta |
| Compute engine | Databricks SQL Warehouse | Singdata Lakehouse |
| Connection method | host + http_path + token | instance + workspace + service + username + password |
| Target catalog | catalog: dbt_blueprint | Not needed (workspace is the catalog) |
| SQL dialect | Databricks SQL | Lakehouse SQL (ANSI-compatible) |
:: cast | Supported | Supported (same on both sides, no change needed) |
SELECT * EXCEPT | Supported | Supported (same on both sides, no change needed) |
DATEDIFF(year, s, e) | Supported | Supported (three-argument form compatible) |
getdate() | Supported | Not supported → use current_date() |
| Model logic (CTE/Window/JOIN) | — | Fully identical |
Project Background
The data comes from a simulated P2P/P2B payment platform and contains 9 raw event tables:
| Domain | Table | Rows | Description |
|---|---|---|---|
| Users | user_events | 196 | User registration/status change events (SCD2 source) |
| Merchants | merchant_events | 30 | Merchant registration/status changes |
| Merchants | industry_codes | 30 | Industry code reference table |
| Accounts | account_events | 80 | Bank account opening/change events |
| Bank cards | card_events | 60 | Card activation/status changes |
| Transactions | raw_p2p_captured_events | 150 | Successful P2P transactions |
| Transactions | raw_p2p_failed_events | 50 | Failed P2P transactions |
| Transactions | raw_p2b_captured_events | 80 | Successful P2B transactions |
| Transactions | raw_p2b_failed_events | 30 | Failed P2B transactions |
dbt four-layer architecture:
Migration Steps
Step 1: Switch the Adapter (Core Change)
The original profiles.yml uses type: databricks. The migration only requires switching to type: clickzetta, replacing Databricks connection params host/http_path/token with Lakehouse params instance/workspace/service:
Also update the profile name in dbt_project.yml:
Step 2: Replace getdate()
getdate() is a SQL Server/Databricks function. Lakehouse uses current_date():
Step 3: Update the Target Name in the generate_schema_name Macro
The original macro uses databricks_cluster as the prod environment name. Change it to clickzetta_prod:
Fully Compatible Parts (No Changes Needed)
The following patterns are written identically on both sides and have been tested end-to-end:
dbt Test Results
Tested on the AWS Singapore instance (aws_singapore_prod), 36/36 all passing:
Data quality tests include: not_null/unique constraints on source tables, marts-layer data contracts (contract: enforced: true), and column type validation on fact_transaction. Unit tests cover SCD2 logic (int_users__scd_logic), transaction aggregation (int_transactions__union_all), and the age calculation macro (calculate_age__valid_ages).
Notes
getdate()vscurrent_date(): Databricks'getdate()returns the current timestamp. Lakehouse usescurrent_date()(date) orcurrent_timestamp()(timestamp) as replacements. Thecol :: typecast syntax and the three-argumentDATEDIFF(year, s, e)form are both natively supported in Lakehouse — no changes needed.- Catalog hierarchy: Databricks uses three-part naming (
catalog.schema.table). In dbt with Lakehouse, onlyschema.tableis used; the adapter handles the rest automatically. No manual changes to table references in models are needed. - Seeds replacing the ingestion layer: The original project relies on ingestion tables in the Databricks workspace. After migrating to Lakehouse, seeds CSVs are used as replacements. In production, these can be replaced with Studio data integration or CDC tasks.
Related Documentation
dbt Development Guides
- dbt Quick Start: dbt-clickzetta adapter installation and configuration
- dbt Incremental Models: Incremental strategy configuration and unique_key options
- dbt Data Quality Checks: Data tests, contract validation, and custom tests
- dbt Advanced Features: Macros, snapshots, semantic layer, and more
Other Migration Case Studies
- Databricks Notebook → Lakehouse Migration (Retail Medallion Pipeline): PySpark Notebook → ZettaPark/Studio tasks
- dbt BigQuery Migration: Retail Data Warehouse Pipeline: BigQuery → Lakehouse adapter migration
- dbt Snowflake Migration: TPC-H Data Warehouse Pipeline: Snowflake → Lakehouse adapter migration
