Skip to content

Getting started

Introduction

Evidence-backed SQL translation: convert Snowflake and Databricks SQL into DuckDB SQL, or refuse it with coded diagnostics.

SQLBabel translates Snowflake and Databricks SQL into DuckDB SQL. Every conversion comes from a rule proven against results recorded on the source warehouse. Anything no rule covers is refused with a code, the exact span and a reason. For Snowflake it also reports, with rustc-style diagnostics, the SQL Snowflake would reject. See Dialects for what each dialect supports.

$ sqlbabel convert revenue.sql --no-config
error[SBL0004]: SQLBabel doesn't know this name
--> revenue.sql:2:6
|
2 | FROM orders
| ^^^^^^ relation `ORDERS` has no known columns
|
= help: declare the relation and its columns in a source file of the project (`sources/*.yml`)
sqlbabel convert: refused, 1 refusal

Once sources/orders.yml declares ORDERS, the same file converts:

$ sqlbabel convert revenue.sql --no-config
SELECT
"ORDERS"."CUSTOMER_ID" AS "CUSTOMER_ID",
CAST(sum("ORDERS"."TOTAL") AS DECIMAL(24, 2)) AS "REVENUE"
FROM "ORDERS"
WHERE ("ORDERS"."STATUS" = 'shipped')
GROUP BY "ORDERS"."CUSTOMER_ID"
sqlbabel convert: done, converted
Step Command Result
Parse and check sqlbabel check What Snowflake would reject, as coded diagnostics. No schema needed.
Convert sqlbabel convert DuckDB SQL for each statement, or the refusals that stop it.
Convert a function sqlbabel function A SQL project function’s body as a DuckDB macro.
Measure a project sqlbabel census Which files convert, and a diagnostic for each that doesn’t.
Trace rules sqlbabel index Which rules and building blocks each file’s conversion relies on.

Converted SQL is proven only where both sessions run in UTC: Snowflake’s TIMEZONE and DuckDB’s TimeZone must be 'UTC'. See Sessions.