Tuple
A tuple is an ordered sequence of values with a fixed arity and a type per position. Tuples are useful when you care about position rather than names—for example pairs produced by zip() or key/value pairs used with map helpers.
Tuples are different from structs: structs use named fields (user.name); tuples use fixed positional accessors (t.f0, t.f1, …).
Tuple literals
Use parentheses with comma-separated expressions. A trailing comma is allowed (including for a one-element tuple).
SET empty_ok = (1,)
SET pair = (1, 'hello')
SET triple = (1, 'hello', true)
Pair shorthand
Two values can be written as a labelled pair left : right (same syntax as a single map entry). It is equivalent to a two-element tuple (left, right) in the usual case:
SET kv = 'status': 200
Tuple types
In casts and type annotations, use the tuple(...) form with one type per position:
tuple(int, string)
tuple(string, int, boolean)
Accessing elements
Tuple fields are named f0, f1, f2, … (zero-based index). Use dot notation like structs:
SET t = (10, 'foo', true)
| SELECT first = t.f0, second = t.f1, third = t.f2
There are no arbitrary field names on tuples—only these positional names.
Tuples vs structs
| Struct | Tuple | |
|---|---|---|
| Syntax | { name: value, ... } | (a, b, ...) or 'key': value for pairs |
| Fields | Named (user.email) | Positional (t.f0, t.f1) |
| SQL feel | Named columns / rows with named fields | Anonymous row / positional columns |
Use a struct when names carry meaning in your schema; use a tuple when order is the contract (pairs, zip results, or APIs that return anonymous rows).