Scalar expressions are available in projection, WHERE, HAVING, and some
other clauses, subject to the clause-specific limits in the
SELECT reference.
Supported expression forms:
| Form | Example |
|---|---|
| Column reference | user_id, events.user_id |
| Literal | 42, 3.14, 'text', true, NULL |
| Arithmetic | a + b, a - b, a * b, a / b |
| Comparison | a = b, a <> b, a > b, a <= b |
| Boolean logic | a AND b, a OR b, NOT a |
| Cast | CAST(a AS BIGINT) |
| Null test | a IS NULL, a IS NOT NULL |
| Between | score BETWEEN 0 AND 1 |
| Pattern match | name LIKE 'spql.%', name ILIKE 'spiraldb.%' |
| Simple searched case | CASE WHEN ok THEN value ELSE 0 END |
| Function call | add(left => a, right => b) or spql.add(a, b) when present in the engine callable catalog |
Current limitations:
- Unary minus for general expressions is not supported.
IS TRUE,IS FALSE,IS UNKNOWN, andIS DISTINCT FROMare not supported.TRY_CASTis not supported.LIKE ANY,ILIKE ANY,LIKE ... ESCAPE,ILIKE ... ESCAPE,SIMILAR TO, andRLIKEare not supported.IN, subquery expressions, tuples, and arrays are not yet supported by the binder.CASEsupports one searchedWHENbranch and requiresELSE.- Function calls support positional and named arguments. Function parameters,
DISTINCT,FILTER, call-levelORDER BY, andOVERare not supported.
Cast targets
Supported cast target names include:
BOOLEANTINYINT,INT8,I8SMALLINT,INT16,I16INT,INTEGER,INT32,I32BIGINT,INT64,I64UINT8,U8UINT16,U16UINT32,U32UINT64,U64REAL,FLOAT,FLOAT32,F32DOUBLE,FLOAT64,F64VARCHAR,TEXT,STRING,UTF8DECIMAL(p[, s]),NUMERIC(p[, s])
All cast targets currently bind as nullable output types.
Registered extension dtype factories are also valid cast targets. The default
core session installs spiral-datetime, which registers temporal factories:
SELECT
CAST(day_number AS date(days)) AS day,
CAST(ts_ms AS timestamp(ms, 'UTC')) AS event_time
FROM events;Plugin factories such as blob(), jpeg(), jpeg_bytes(), exif(), and
image_view() are available when the corresponding default CLI plugins are
registered.
Temporal functions
The default core session also registers named datetime functions under
spql.dt. Use these names directly; standard SQL temporal syntax such as
DATE '2026-06-29', EXTRACT, AT TIME ZONE, and INTERVAL is still a
planned compatibility layer.
SELECT
spql.dt.to_date('2026-06-29') AS day,
spql.dt.year(spql.dt.to_timestamp('2026-06-29T12:34:56')) AS year,
spql.dt.duration_total(spql.dt.to_duration('2h'), 's') AS seconds;Datetime generators are table functions and emit a top-level value column:
SELECT value
FROM spql.dt.bdate_range('2026-06-29', '2026-07-03');Implemented generators include spql.dt.date_range,
spql.dt.timestamp_range, spql.dt.time_range, spql.dt.timedelta_range,
spql.dt.period_range, spql.dt.bdate_range, and
spql.dt.generate_series.