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:
- Numeric types:
INTEGER,BIGINT,DOUBLE,DECIMAL,HUGEINT - Text types:
VARCHAR,TEXT - Temporal types:
DATE,TIMESTAMP,TIMESTAMPTZ,TIME,INTERVAL - Binary types:
BLOB,BITSTRING - Boolean type:
BOOLEAN - Nested types:
ARRAY,LIST,MAP,STRUCT,UNION - Special types:
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.