Skip to content
DocumentationLakehouse
Lakehouse
SQL engine

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:

SQL
SELECT
distinct_id,
COUNT(*) AS sessions
FROM product_analytics.analytics.web_sessions
WHERE started_at >= date_trunc('week', now())
GROUP BY distinct_id
ORDER BY sessions DESC
LIMIT 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:

SQL
SELECT
u.email,
b.total_revenue
FROM pg_production.users u
JOIN bigquery.revenue b
ON 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.

JSON
{
"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

  1. You send statement in the source dialect and set dialect to that engine.
  2. Altertable transpiles the SQL to DuckDB using polyglot-sql.
  3. 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.