SQL
On this page
Functions
NextSQL function names are case-insensitive. Arguments are type checked and are not silently converted between unrelated types. Unless a function says otherwise, a SQL NULL argument produces NULL.
String functions#
String functions accept STRING, TEXT, CHAR, and VARCHAR values. A CHAR argument is treated as its content without storage padding; VARCHAR is treated as STRING. Results preserve TEXT where applicable.
CONCAT is variadic but requires at least one argument. Every argument must be a string type. It follows NextSQL's normal NULL propagation, so CONCAT('a', NULL) returns NULL rather than treating NULL as an empty string.
Numeric functions#
The exact functions do not pass through binary floating point. POWER rejects non-finite results and SQRT rejects negative inputs.
NULL and value functions#
COALESCE is lazy: arguments after the first non-NULL value are not evaluated. All four functions require at least one argument except NULLIF, which requires exactly two.
Date and time functions#
Date/time functions use UTC and accept year, month, day, hour, minute, and second units.
Unknown units and non-integral DATE_ADD amounts are rejected.
JSON functions#
These functions operate directly on validated binary NSJB documents. Paths may use a.b.0 or $.a.b.0 notation. See JSON for storage, limits, and index behavior.
A constant-path JSON_GET(column, path) predicate is matched to the same native path expression used by JSON-path indexes. A dynamic path remains a runtime call and is not considered sargable.
Aggregate functions#
Aggregate arguments may be computed expressions. Aggregates can also appear in larger select expressions, such as COUNT(*) + 1. See Relational for grouping and HAVING behavior and Collections for collection aggregates.
Window functions#
Supported window calls are ROW_NUMBER(), RANK(), DENSE_RANK(), LAG(value [, offset [, default]]), LEAD(value [, offset [, default]]), FIRST_VALUE(value), LAST_VALUE(value), and COUNT / SUM / AVG / MIN / MAX with OVER (...).
Window expressions support PARTITION BY, window ORDER BY, and bounded ROWS or RANGE frames. They run after filtering and grouping but before query-level DISTINCT, ordering, and limits. See Relational for the full frame and NULL-ordering rules.
Collection functions#
STRUCT(...), ARRAY(...), and MAP(...) construct collection values; subscript syntax is shorthand for ELEMENT_AT. See Collections for constructors, nesting limits, aggregates, and UNNEST.
Vector functions#
Arguments must have equal dimensions and finite values. Some algebra operations are intentionally unavailable for SPARSEVECTOR or BITVECTOR; see Vectors for the exact type/metric matrix and ANN behavior.
Geospatial functions#
The fixed WGS84 types provide POINT, BOX, LINESTRING, POLYGON, LON, LAT, DISTANCE, DISTANCE_SPHEROID, DWITHIN, WITHIN, COVERS, INTERSECTS, DISJOINT, LINELENGTH, AREA, PERIMETER, CENTROID, ENVELOPE, GEOMETRYTYPE, NPOINTS, and NRINGS, including documented ST_* aliases.
General GEOMETRY / GEOGRAPHY adds constructors and serializers such as ST_GEOMFROMTEXT, ST_GEOGFROMTEXT, ST_POINT, ST_ASTEXT, ST_ASBINARY, ST_ASGEOJSON, and ST_GEOMFROMGEOJSON; accessors and measurements such as ST_SRID, ST_DIMENSION, ST_LENGTH, and ST_AREA; topological predicates; overlay operations; ST_BUFFER, ST_SIMPLIFY, ST_SEGMENTIZE, and the bounded ST_TRANSFORM subset. See Geospatial for native semantics, supported aliases, indexability, SRID rules, and limits.
Search result functions#
HIGHLIGHT(value [, pre, post]) and SNIPPET(value [, width [, pre, post]]) are valid only in a SELECT list with a SEARCH clause. Snippet width is 16–4096 Unicode code points (default 160). Both fail closed in predicates, grouping, joins, and DML. See Full-text search for analyzer and marker behavior.
Execution-time defaults#
UUID(), NOW(), and AI() are evaluated during execution and are not folded by the optimizer. AI() is only valid as a DECIMAL(p,0) column default and allocates in the statement transaction, so a rollback reuses the number.