SQL engine
Dialect
Altertable uses the DuckDB SQL dialect for all queries. If you are familiar with PostgreSQL or SQLite, most core syntax will be familiar.
Example query when Product Analytics is enabled for the environment:
SELECTdistinct_id,COUNT(*) AS sessionsFROM product_analytics.analytics.web_sessionsWHERE started_at >= date_trunc('week', now())GROUP BY distinct_idORDER BY sessions DESCLIMIT 10;
For complete syntax reference, see the DuckDB SQL Documentation.
Data types
Altertable supports the same data types as DuckDB, including:
Category | Types |
|---|---|
Numeric | INTEGER, BIGINT, DOUBLE, DECIMAL, HUGEINT |
Text | VARCHAR, TEXT |
Temporal | DATE, TIMESTAMP, TIMESTAMPTZ, TIME, INTERVAL |
Binary | BLOB, BITSTRING |
Boolean | BOOLEAN |
Nested | ARRAY, LIST, MAP, STRUCT, UNION |
Special | UUID, JSON |
For a complete list of supported data types and their specifications, see the DuckDB Data Types Overview.
Federated queries
Connect multiple data sources, from BigQuery to Postgres catalogs, in the same SQL namespace:
SELECTu.email,b.total_revenueFROM pg_production.users uJOIN bigquery.revenue bON u.id = b.user_id;
The engine handles cross-catalog federation automatically, optimizing query execution across all data sources in your lakehouse.
Transpile another SQL dialect
Altertable executes DuckDB SQL. Most of the lakehouse—SQL Explorer, Postgres adapter, dashboards—assumes you write DuckDB syntax directly.
The dialect parameter is different: it lets you send SQL written for another engine and have Altertable transpile it to DuckDB before execution. That is useful when you are porting saved queries from another platform, running BI-generated SQL, or prototyping a migration without rewriting every function by hand.
{"statement": "SELECT DATEDIFF(day, start_date, end_date) AS days FROM my_catalog.main.orders","dialect": "snowflake"}
Altertable transpiles the statement, then runs the DuckDB version on your catalog.
How it works
- You send
statementin the source dialect and setdialectto that engine. - Altertable transpiles the SQL to DuckDB using polyglot-sql.
- The transpiled statement runs on Workers like any other query.
Omit dialect (or write DuckDB SQL and leave it unset) when you already target DuckDB. Transpilation is optional, not the default path.
Dialect names are case-insensitive. Some engines accept aliases—for example, tsql, mssql, and sqlserver all map to SQL Server.
Common source dialects
Transpilation coverage depends on the source dialect and the functions in your SQL. These are the engines teams most often port from:
dialect value | Source engine |
|---|---|
snowflake | Snowflake |
databricks | Databricks |
bigquery | Google BigQuery |
spark | Apache Spark SQL |
trino | Trino |
presto | Presto |
redshift | Amazon Redshift |
postgresql | PostgreSQL |
mysql | MySQL |
tsql | Microsoft SQL Server |
clickhouse | ClickHouse |
athena | Amazon Athena |
Many other dialects are supported, including hive, oracle, sqlite, teradata, and fabric. Unknown dialect names return 400 Bad Request.
Check the query API reference for the complete request shape and all supported parameters.