SQL reference

SQL reference

VegaDB syntax, statements, data types, operators, functions and behavioral contracts.

VegaDB SQL is an analytical SQL language whose dialect follows DuckDB's. The same language runs over Arrow Flight SQL, Spark Connect (spark.sql) and the HTTP SQL API. Identifiers are case-insensitive unless quoted. String literals use single quotes; quoted identifiers use double quotes.

SELECT
  customer_id,
  date_trunc('month', ordered_at) AS month,
  sum(net_amount) AS revenue
FROM lakehouse.sales.orders
WHERE status = 'paid'
GROUP BY ALL
QUALIFY revenue > 1000
ORDER BY month DESC;

Reference map

Language coverage

AreaIncluded surface
Queryprojections, filters, joins, subqueries, CTEs, set operations, grouping and ordering
Analyticswindows, QUALIFY, grouping sets, cube, rollup, pivot, unpivot and sampling
Data definitioncatalogs, schemas, tables, views and materialized views
Data modificationinsert, update, delete, merge and truncate on managed catalogs
Typesscalar numeric/text/binary/temporal plus list, array, struct, map, union, JSON and UUID
Functionsscalar, aggregate, approximate, window, nested-data, JSON, date/time and vector families
Client useprepared parameters, streamed Arrow results, sessions and multi-statement transactions over Flight SQL, Spark Connect and the HTTP SQL API

Compatibility and availability

  • Supported means the syntax and result behavior are part of the VegaDB warehouse contract.
  • Bounded means the construct has a documented row, byte, state, output-column or recursion limit.
  • Unavailable means VegaDB rejects the operation with a specific error instead of silently changing its meaning.

A query can be valid SQL and still be unavailable for a catalog, warehouse profile or release. The returned error identifies the unsupported operation or exceeded limit.

Parameters

Prepared statements take positional parameters (?, or numbered $1, $2, …). Flight SQL drivers bind values as Arrow data, so nested values arrive with their own STRUCT, MAP, LIST or ARRAY types; cast a parameter when its type cannot be inferred from the expression around it.

SELECT $1::BIGINT AS account_id,
       $2::STRUCT(name VARCHAR, active BOOLEAN) AS profile;

NULL

VegaDB uses SQL three-valued logic. NULL = NULL is NULL, not TRUE; use IS NOT DISTINCT FROM for NULL-safe equality. Aggregates generally ignore NULL inputs except functions such as first, last and list-producing aggregates where NULL is part of the selected value.

SELECT
  NULL = NULL AS unknown,
  NULL IS NOT DISTINCT FROM NULL AS null_safe_true;

Availability is explicit

Reference pages distinguish supported behavior from catalog-dependent writes. Because overloads can be added with a warehouse release, information_schema.routines is the final machine-readable inventory for the warehouse to which a client is connected. Documentation should never be used to infer that an unlisted function or syntax variant is silently accepted.

Vegalake, VegaDB and VegaFlow are trademarks or registered trademarks of Vegalake Inc.

On this page