Skip to main content
Sumatra’s function catalog is deliberately small: a basic programming language’s daily-use kernel, not a SQL reference. The split to remember:
  • Inside the opaque read (and inside server-side statements) you are writing the engine’s SQL — every function the engine has is available there, and heavyweight transformation (regex, format masks, text parsing) belongs there.
  • In compute position — expressions on variables and rec fields — the functions on this page are the supported set. They run in Sumatra’s own evaluator, bit-exact to the engine’s semantics.
Unless noted otherwise, a NULL argument makes the result NULL.

Null handling

Operands of GREATEST, LEAST (and CASE arms) must share a type family — mixing TEXT with numbers or dates is a compile error asking for an explicit CAST, rather than a runtime coercion that faults only on bad data.

Math

Division is the / operator; dividing by zero faults with ZERO_DIVIDE (see numeric semantics for the width, promotion, and overflow rules).

Text

Two operator companions: || concatenates two strings (NULL propagates), and LIKE (with the usual % and _ wildcards) is the language’s pattern match.

Date and time

The unit is a quoted string, first argument: 'year', 'month', 'day', 'hour', 'minute', 'second'.
An out-of-range result (before year 1 or after year 9999) faults with OVERFLOW. Time parts cannot be extracted from a plain DATE. INTERVAL arithmetic (ts - INTERVAL '24' HOUR) is SQL-side — use it inside reads and write statements.

Casts and conversions

CAST(x AS T) and the shorthand x::T convert between compute types: These are the same conversions assignment applies implicitly when the declared type differs from the value’s type.