SPQL
Look up every SPQL function and data type, with signatures that hold wherever you call them.
SPQL is Spiral's library of functions and data types for working with Table
data, from string and date functions such as spql.str.upper and
spql.dt.year to image decoding and tensor math. A function name means the
same thing everywhere you can call it: inside a Scan next to storage, on Arrow
batches your application holds, or in a DataFusion query. So a value computed
in one place matches the value computed in the others, and you can move work
between them without changing results.
This reference lists every function with its signatures. Each function is a
scalar function: it computes one value from the values in one row.
Enrichment expressions use the same functions.
To see exactly which functions and argument types your native library
provides, call Functions::list.
Read a signature
One function name can accept several combinations of argument types. Each combination is an overload, with its own parameter types, output type, and nullability. When you call a function, Spiral picks the overload that matches your argument types before any rows are read. If none matches, the call fails right away. SPQL never casts arguments implicitly, so add an explicit cast when your types differ.
Some parameters must be literal values, such as a format name or a unit. A
signature shows a literal parameter as a placeholder value, such as 'method'
or 1, instead of a name. An optional parameter has a ? suffix.
The type after -> is the result. A ? on a type means it can be null.
type(value) preserves that argument's type and nullability. An inferred
result depends on the argument types; a declared result is supplied by the
caller. Notes below each signature explain conditional nullability and any
refinement by literal arguments.
Namespaces
A function's name starts with a namespace that groups related functions, for example:
| Namespace | Area |
|---|---|
spql.str | Strings. |
spql.dt | Dates, times, durations, and periods. |
spql.io | Blobs, URIs, archives, and byte input and output. |
spql.image | Image types, metadata, and decoding. |
spql.tensor | Tensor and vector operations. |
Data types
Signatures use the type names on the data types
page. Semantic types, such as vector(n) or an image, give a meaning to a
storage layout. Each semantic type has its own type ID, so a function that
expects a vector rejects an arbitrary fixed-size list with the same layout.
Call a function
- In a Scan, build the call with
Expression::call. See Reading. - On your own Arrow batches, evaluate the calls with
Functions. See Functions. - In SQL, register the functions with
with_spqland quote the dotted name, as in"spql.str.upper"(camera). See DataFusion.
The expressions page explains where each expression runs.
Functions by domain
Each page documents one domain. For each function, it gives the signatures, the parameter types, and the result. The data types page defines the type names that the signatures use.
| Domain | Functions | Summary |
|---|---|---|
| Expressions & Operators | 21 | Compare values and combine arithmetic and logical expressions. |
| Strings | 21 | Transform, measure, and match text values. |
| Binary & Hashing | 13 | Encode, inspect, and hash byte values. |
| Math | 24 | Apply numeric rounding, logarithmic, root, and trigonometric functions. |
| Lists | 5 | Measure, search, and reduce list values. |
| Date & Time | 48 | Construct, extract, and transform dates, times, timestamps, durations, and periods. |
| Blobs & I/O | 15 | Work with URI-backed byte payloads, blob metadata, and archive ingestion. |
| Images | 12 | Decode and encode display-oriented images, inspect properties, and read JPEG metadata. |
| Depth Maps | 8 | Inspect depth samples, representation, confidence, and calibration metadata. |
| Object Detection | 3 | Inspect detected object labels, bounding boxes, and confidence scores. |
| Video | 16 | Inspect encoded media and MP4 structure, select video frames, and decode images. |
| Tensors & Vectors | 7 | Tensor and vector math, including similarity measures and norms. |
| Model Inference (planned) | 8 | Run admitted, revision-pinned models over typed multimodal values. |
| Robotics | 35 | Ingest robotics logs such as MCAP, and construct poses, transforms, point clouds, scenes, annotations, and sensor values. |
| Geospatial | 13 | Measure distances and evaluate spatial predicates over geometries (points, polygons, and multipolygons). |
| Visualization | 45 | Construct typed views, charts, spatial primitives, and layouts. |