SQL reference

Data types

Scalar, temporal and nested types supported by VegaDB SQL and PostgreSQL clients.

Numeric

TypeNotes
TINYINT, SMALLINT, INTEGER, BIGINT, HUGEINTSigned integers from 8 to 128 bits.
UTINYINT, USMALLINT, UINTEGER, UBIGINT, UHUGEINTUnsigned integer families. Client binary support varies; text is portable.
DECIMAL(p, s) / NUMERIC(p, s)Exact fixed-point numbers. Choose scale deliberately for money.
REAL, FLOAT, DOUBLEIEEE floating-point families. Not exact decimal storage.

Arithmetic follows VegaDB type-promotion rules. PostgreSQL wire compatibility does not imply that every PostgreSQL cast or overflow behavior is identical; use TRY_CAST when conversion failure should return NULL.

Boolean and text

BOOLEAN, VARCHAR, TEXT, CHAR, BLOB, BIT and ENUM are supported. VARCHAR length is not a storage limit. Use a check or application contract when length is part of the business rule.

Temporal

TypeMeaning
DATECalendar date without time.
TIME, TIME_NSTime of day, with microsecond or nanosecond precision.
TIMETZTime of day with time-zone offset.
TIMESTAMP, TIMESTAMP_NSDate and time without time zone.
TIMESTAMPTZAbsolute instant rendered in a session time zone.
INTERVALMonths, days and microseconds as distinct components.
SELECT
  TIMESTAMPTZ '2026-09-03 10:00:00+04:00',
  date_trunc('hour', event_time),
  event_time AT TIME ZONE 'UTC';

UUID and JSON

UUID, JSON and JSONB are available. JSON text is validated when cast. Use typed nested data when the schema is stable and JSON when its shape is genuinely open.

SELECT
  payload->>'event_type' AS event_type,
  json_extract(payload, '$.items[0].sku') AS first_sku
FROM raw_events;

LIST and ARRAY

LIST stores a variable-length homogeneous sequence. ARRAY stores a fixed-length homogeneous sequence.

SELECT [1, 2, 3]::INTEGER[] AS values,
       array_value(0.12, 0.44, 0.91)::DOUBLE[3] AS embedding;

Lists support slicing, containment, concatenation, ordering, filtering, transformation, reduction, zipping and flattening. Fixed arrays support distance, dot product and cosine functions useful for vector work.

STRUCT

STRUCT is a typed record with named fields.

SELECT {
  name: 'Mira',
  address: {city: 'Dubai', country: 'AE'}
}::STRUCT(
  name VARCHAR,
  address STRUCT(city VARCHAR, country VARCHAR)
) AS customer;

Access a field with dot notation or struct_extract. Names are part of the type identity.

MAP

MAP(K, V) contains key/value pairs with a single key type and value type.

SELECT map(['currency', 'channel'], ['AED', 'web']) AS attributes;

UNION and VARIANT

UNION is a tagged choice among declared member types. VARIANT holds recursive semi-structured values while retaining native scalar/container identity.

Nested results are encoded as canonical JSONB for PostgreSQL clients where the protocol has no native equivalent. Prepared nested input must name the target type explicitly so the server can convert each JSON value without guessing.

NULL and nested values

The container can be NULL, and values inside it can be NULL. Those are distinct cases. A JSON null passed to a typed prepared parameter is converted according to the exact nested target and is not treated as an untyped SQL string.

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

On this page