Skip to main content
ToraDB SQL supports built-in scalar functions (string, numeric, date/time, conditional) and column aliases. Functions are usable in SELECT, WHERE, ORDER BY, and GROUP BY, and can be nested (lower(trim(title))). Arguments are columns, literals, or other functions.

Column aliases

Rename an output column with AS. The AS keyword is optional.
The alias becomes the output column name (the JSON key in API/SDK responses). Without an alias, a column keeps its name, a function uses its canonical text (lower(title)), and an aggregate uses its default name (sum_amount, count).
Aliases only rename output columns. They are not referenceable from WHERE, ORDER BY, or GROUP BY — repeat the expression there instead. SELECT DISTINCT dedupes on the underlying expression, not the alias.

Scalar functions in SELECT

Each function is evaluated per row; the columns it references are fetched automatically.

Scalar functions in WHERE

The function is evaluated for each candidate, then compared against the literal. A NULL result never matches.

Scalar functions in ORDER BY

ORDER BY score (relevance) remains the default for retrieval queries.

Scalar functions in GROUP BY

Aggregates can also wrap a function:

Function reference

String

Numeric

Date / time

Timestamps are parsed from stored Date/Timestamp columns (ISO YYYY-MM-DD[THH:MM:SS]).

Conditional

NULL handling

A missing column evaluates to NULL. Functions propagate NULL (a NULL argument yields NULL) except coalesce/ifnull (which skip nulls), nullif, and concat (which treats NULL as the empty string). In projection, NULL renders as an empty string.

Limitations

  • Functions on the left of IN, BETWEEN, LIKE, and in HAVING are not supported yet — use a plain comparison (func(x) = 'y').
  • ORDER BY <function> is not supported on materialized views (cached rows lack the source columns).
  • Aggregate over a function (SUM(abs(x))) cannot reference text in the GROUP BY scan path.
Unknown function names and wrong argument counts are rejected at parse time.