This is the full catalog of operators in the unified algebra. Each entry gives
you:
what it does , in plain language;
its signature : the arguments and their types, and what it returns;
its semantics : the precise definition.
Notation used throughout: V \mathcal{V} V is the domain of items, T \mathcal{T} T
the set of tuples, A \mathcal{A} A the set of attribute names, ⊕ \oplus ⊕ is
tuple concatenation , and
Γ \Gamma Γ is the operator context .
i n s t … \mathrm{inst}_{\dots} inst … marks an argument that is re-instantiated per row (a
horizontal input ).
Each operator's formal definition abbreviates its arguments to single letters;
the argument list under every entry gives that letter in parentheses, e.g.
attrs (A A A ).
The tables below are a per-group index; the operator name links down to its full
entry.
Item operators
Item operators produce streams of opaque values. Most are calculation
intermediaries : building blocks assembled inside a
Calculation rather than standalone plan nodes.
Operator Notation Result schema Calculation intermediaries AggregateCall a g g ( args ) \mathrm{agg}(\texttt{args}) agg ( args ) n/a Conditional c o n d ( expr , whenthens , default ) \mathrm{cond}(\texttt{expr}, \texttt{whenthens}, \texttt{default}) cond ( expr , whenthens , default ) n/a FnCall f n ( impl , args ) \mathrm{fn}(\texttt{impl}, \texttt{args}) fn ( impl , args ) n/a Literal l i t e r a l ( value ) \mathrm{literal}(\texttt{value}) literal ( value ) n/a Quantifier q u a n t ( type , query ) \mathrm{quant}(\texttt{type}, \texttt{query}) quant ( type , query ) n/a Other Calculation c a l c ( impl , args ) \mathrm{calc}(\texttt{impl}, \texttt{args}) calc ( impl , args ) n/a ItemSource name \textit{name} name n/a ItemFnSource name ( impl , params ) \textit{name}(\texttt{impl}, \texttt{params}) name ( impl , params ) n/a MapToItem t o I t e m ( key , source ) \mathrm{toItem}(\texttt{key}, \texttt{source}) toItem ( key , source ) n/a
AggregateCall
Represents the result of a single aggregate (such as count or sum) applied
to a partition produced by an upstream GroupBy . It's a placeholder
that the GroupBy fills in for each group.
Signature: a g g ( args ) \mathrm{agg}(\texttt{args}) agg ( args )
API: AggregateCall
Conditional
A CASE / if-then-else expression. It scans the whenthens pairs and returns
the value of the first one whose condition matches, falling back to default.
With an expr, each branch is compared against that value (a switch); without
one, each branch condition is tested for truth (an if/elif chain).
Signature: c o n d ( expr , whenthens , default ) \mathrm{cond}(\texttt{expr}, \texttt{whenthens}, \texttt{default}) cond ( expr , whenthens , default )
API: Conditional
expr (e e e ): S t r e a m 01 ( V ) \mathrm{Stream}_{01}(\mathcal{V}) Stream 01 ( V )
whenthens (w w w ):
S e q ( ( S t r e a m 01 ( V ) , S t r e a m 01 ( V ) ) ) \mathrm{Seq}((\mathrm{Stream}_{01}(\mathcal{V}), \mathrm{Stream}_{01}(\mathcal{V}))) Seq (( Stream 01 ( V ) , Stream 01 ( V )))
default (d d d ): S t r e a m 01 ( V ) \mathrm{Stream}_{01}(\mathcal{V}) Stream 01 ( V )
returns : S t r e a m 1 ( V ) \mathrm{Stream}_{1}(\mathcal{V}) Stream 1 ( V )
c o n d ( e , w , d ) = { ⟨ w i , 1 ⟩ where i is the first index with w i , 0 = e , else d , if e is provided ⟨ w i , 1 ⟩ where i is the first index with w i , 0 = ⟨ true ⟩ , else d , otherwise \mathrm{cond}(e, w, d) = \begin{cases}
\langle w_{i,1}\rangle \text{ where } i \text{ is the first index with } w_{i,0} = e, \text{ else } d, & \text{if } e \text{ is provided} \\[6pt]
\langle w_{i,1}\rangle \text{ where } i \text{ is the first index with } w_{i,0} = \langle\textbf{true}\rangle, \text{ else } d, & \text{otherwise}
\end{cases} cond ( e , w , d ) = ⎩ ⎨ ⎧ ⟨ w i , 1 ⟩ where i is the first index with w i , 0 = e , else d , ⟨ w i , 1 ⟩ where i is the first index with w i , 0 = ⟨ true ⟩ , else d , if e is provided otherwise
FnCall
Calls a scalar function on its arguments and yields a single value. It's the
building block for ordinary expressions inside a Calculation
(arithmetic, comparisons, string functions, and so on).
Signature: f n ( impl , args ) \mathrm{fn}(\texttt{impl}, \texttt{args}) fn ( impl , args )
API: FnCall
impl (i i i ):
S e q ( S t r e a m ( V ) ) → S t r e a m 1 ( V ) \mathrm{Seq}(\mathrm{Stream}(\mathcal{V})) \rightarrow \mathrm{Stream}_1(\mathcal{V}) Seq ( Stream ( V )) → Stream 1 ( V )
args (A A A ): S e q ( S t r e a m ( V ) ) \mathrm{Seq}(\mathrm{Stream}(\mathcal{V})) Seq ( Stream ( V ))
returns : S t r e a m 1 ( V ) \mathrm{Stream}_{1}(\mathcal{V}) Stream 1 ( V )
f n ( i , A ) = ⟨ i ( A ) ⟩ \mathrm{fn}(i, A) = \langle i(A) \rangle fn ( i , A ) = ⟨ i ( A )⟩
Literal
A constant value embedded directly in the plan, such as the 3 in x + 3.
Signature: l i t e r a l ( value ) \mathrm{literal}(\texttt{value}) literal ( value )
API: Literal
Quantifier
A SQL-style quantified comparison, for example x > ALL(SELECT y FROM t) or
x = ANY(...). The type says how the comparison is quantified over the
subquery query.
Signature: q u a n t ( type , query ) \mathrm{quant}(\texttt{type}, \texttt{query}) quant ( type , query )
API: Quantifier
Calculation
The general "compute a value" operator, and the only item operator that
routinely appears as a real plan node. It wraps an expression (function calls,
literals, attribute references, even whole subqueries) and evaluates it against
the current row and context. Projection attributes and
Selection conditions are all Calculations. When its expression
contains a subquery, it tracks whether that subquery yields at most one value or
many.
Signature: c a l c ( impl , args ) \mathrm{calc}(\texttt{impl}, \texttt{args}) calc ( impl , args )
API: Calculation
impl (i i i ):
S e q ( S t r e a m ( V ) ) → S t r e a m 1 ( V ) \mathrm{Seq}(\mathrm{Stream}(\mathcal{V})) \rightarrow \mathrm{Stream}_1(\mathcal{V}) Seq ( Stream ( V )) → Stream 1 ( V )
args (A A A ): S e q ( S t r e a m ( V ) ) \mathrm{Seq}(\mathrm{Stream}(\mathcal{V})) Seq ( Stream ( V ))
returns : S t r e a m 1 ( V ) \mathrm{Stream}_{1}(\mathcal{V}) Stream 1 ( V )
c a l c ( i , A ) = ⟨ i ( A ) ⟩ \mathrm{calc}(i, A) = \langle i(A) \rangle calc ( i , A ) = ⟨ i ( A )⟩
ItemSource
A named source that emits opaque items, for example a graph's nodes or
edges, or a registered JSON array. The leaf of an item pipeline.
Signature: name \textit{name} name
API: ItemSource
ItemFnSource
Like ItemSource , but the items come from calling a function
with parameters rather than from a named registration. Cypher's UNWIND lowers
to this.
Signature: name ( impl , params ) \textit{name}(\texttt{impl}, \texttt{params}) name ( impl , params )
API: ItemFnSource
impl (i i i ):
S e q ( S t r e a m 1 ( V ) ) → S t r e a m ( V ) \mathrm{Seq}(\mathrm{Stream}_1(\mathcal{V})) \rightarrow \mathrm{Stream}(\mathcal{V}) Seq ( Stream 1 ( V )) → Stream ( V )
params (A A A ): S e q ( S t r e a m 1 ( V ) ) \mathrm{Seq}(\mathrm{Stream}_1(\mathcal{V})) Seq ( Stream 1 ( V ))
returns : S t r e a m ( V ) \mathrm{Stream}(\mathcal{V}) Stream ( V )
name ( i , A ) = i ( A ) \textit{name}(i, A) = i(A) name ( i , A ) = i ( A )
MapToItem
Turns a tuple stream into an item stream by pulling the key attribute out of
each tuple. If key is the allAttrs symbol *, the whole tuple becomes the
item. The bridge from the tuple world back to the item world.
Signature: t o I t e m ( key , source ) \mathrm{toItem}(\texttt{key}, \texttt{source}) toItem ( key , source )
API: MapToItem
key (k k k ): A \mathcal{A} A
source (S S S ): S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T ) , where
key ∈ s c h e m a ( source ) \texttt{key} \in \mathrm{schema}(\texttt{source}) key ∈ schema ( source )
returns : S t r e a m ( V ) \mathrm{Stream}(\mathcal{V}) Stream ( V )
t o I t e m ( k , S ) = ⟨ t . k ∣ t ∈ S ⟩ \mathrm{toItem}(k, S) = \langle t.k \mid t \in S \rangle toItem ( k , S ) = ⟨ t . k ∣ t ∈ S ⟩
Tuple operators: SPJ and other
Tuple operators produce streams of named rows. These are the relational core of
the algebra.
Operator Notation Result schema Select / Project / Join CartesianProduct × ( left , right ) \times(\texttt{left},\texttt{right}) × ( left , right ) left ⊕ right \texttt{left} \oplus \texttt{right} left ⊕ right Join ⋈ ( left , right , leftOuter , rightOuter , conditions ) \bowtie(\texttt{left},\texttt{right}, \texttt{leftOuter}, \texttt{rightOuter},\texttt{conditions}) ⋈ ( left , right , leftOuter , rightOuter , conditions ) left ⊕ right \texttt{left} \oplus \texttt{right} left ⊕ right Projection π ( attrs , source ) \pi(\texttt{attrs},\texttt{source}) π ( attrs , source ) attrs \texttt{attrs} attrs ProjectionConcat → ⋈ ( mapping , outer , source ) \stackrel{\bowtie}{\rightarrow}(\texttt{mapping}, \texttt{outer}, \texttt{source}) → ⋈ ( mapping , outer , source ) source ⊕ mapping \texttt{source} \oplus \texttt{mapping} source ⊕ mapping ProjectionIndex i n d e x ( key , source ) \mathrm{index}(\texttt{key}, \texttt{source}) index ( key , source ) source ⊕ ( key ) \texttt{source} \oplus (\texttt{key}) source ⊕ ( key ) Selection σ ( expression , source ) \sigma(\texttt{expression}, \texttt{source}) σ ( expression , source ) source \texttt{source} source Other Distinct δ ( attributes , source ) \delta(\texttt{attributes}, \texttt{source}) δ ( attributes , source ) source \texttt{source} source GroupBy γ ( keys , aggs , source ) \gamma(\texttt{keys},\texttt{aggs},\texttt{source}) γ ( keys , aggs , source ) keys ⊕ aggs \texttt{keys} \oplus \texttt{aggs} keys ⊕ aggs MapFromItem f r o m I t e m ( key , source ) \mathrm{fromItem}(\texttt{key}, \texttt{source}) fromItem ( key , source ) ( key ) (\texttt{key}) ( key ) OrderBy τ ( orders , source ) \tau(\texttt{orders},\texttt{source}) τ ( orders , source ) source \texttt{source} source Recursion ϕ ( min , max , condition , source ) \phi(\texttt{min}, \texttt{max}, \texttt{condition}, \texttt{source}) ϕ ( min , max , condition , source ) source \texttt{source} source TupleSource name \textbf{name} name unknown TupleFnSource name ( impl , params ) \textbf{name}(\texttt{impl}, \texttt{params}) name ( impl , params ) possibly unknown
CartesianProduct
Pairs every row on the left with every row on the right: the unfiltered cross
product.
Signature: × ( left , right ) \times(\texttt{left}, \texttt{right}) × ( left , right )
API: CartesianProduct
left (L L L ): S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
right (R R R ): S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
returns : S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
× ( L , R ) = ⟨ l ⊕ r ∣ l ∈ L , r ∈ R ⟩ \times(L, R) = \langle l \oplus r \mid l \in L, r \in R \rangle × ( L , R ) = ⟨ l ⊕ r ∣ l ∈ L , r ∈ R ⟩
Join
A cross product kept only where all conditions hold. Set leftOuter or
rightOuter to also emit unmatched rows from that side, padded with nulls.
Conditions are kept as a set (rather than one combined predicate) so the
optimizer can reason about each separately; a join with no conditions is legal
and useful purely for its outer-join behavior.
Signature:
⋈ ( left , right , leftOuter , rightOuter , conditions ) \bowtie(\texttt{left}, \texttt{right}, \texttt{leftOuter}, \texttt{rightOuter}, \texttt{conditions}) ⋈ ( left , right , leftOuter , rightOuter , conditions )
API: Join
left (L L L ): S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
right (R R R ): S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
leftOuter : Boolean
rightOuter : Boolean
conditions (C C C ):
S e t ( i n s t S t r e a m 1 ( V ) ) \mathrm{Set}(\mathrm{inst}_{\mathrm{Stream}_1(\mathcal{V})}) Set ( inst Stream 1 ( V ) )
returns : S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
⋈ ( L , R , false , false , C , Γ ) = ⟨ l ⊕ r ∣ l ∈ L , r ∈ R , ∀ c ∈ C : c ( Γ ∪ l ∪ r ) = ⟨ true ⟩ ⟩ \bowtie(L, R, \textbf{false}, \textbf{false}, C, \Gamma) = \langle l \oplus r \mid l \in L, r \in R, \forall c \in C: c(\Gamma \cup l \cup r) = \langle\textbf{true}\rangle \rangle ⋈ ( L , R , false , false , C , Γ ) = ⟨ l ⊕ r ∣ l ∈ L , r ∈ R , ∀ c ∈ C : c ( Γ ∪ l ∪ r ) = ⟨ true ⟩⟩
When leftOuter (or rightOuter) is true, unmatched left (or right) rows are
also returned, padded with nulls.
Projection
Computes a new set of named attributes for each row: the algebra's SELECT
list. Each output attribute is a Calculation evaluated against
the row and context.
Signature: π ( attrs , source ) \pi(\texttt{attrs}, \texttt{source}) π ( attrs , source )
API: Projection
attrs (A A A ):
S e q ( i n s t S t r e a m 1 ( V ) × A ) \mathrm{Seq}(\mathrm{inst}_{\mathrm{Stream}_1(\mathcal{V})} \times \mathcal{A}) Seq ( inst Stream 1 ( V ) × A )
source (S S S ): S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
returns : S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
π ( A , S , Γ ) = ⟨ { a ↦ c ( Γ ⊕ s ) ∣ ( c , a ) ∈ A } ∣ s ∈ S ⟩ \pi(A, S, \Gamma) = \langle \left\{ a \mapsto c(\Gamma \oplus s) \mid (c, a) \in A \right\} \mid s \in S \rangle π ( A , S , Γ ) = ⟨ { a ↦ c ( Γ ⊕ s ) ∣ ( c , a ) ∈ A } ∣ s ∈ S ⟩
ProjectionConcat
The depend-join . For each source row, it re-evaluates the mapping subquery
(which may reference that row through the context) and joins each resulting row
back onto the source row. This is how correlated subqueries and LATERAL joins
are expressed. With outer set, source rows that produce no mapping rows are
still emitted, padded with nulls.
Signature:
→ ⋈ ( mapping , outer , source ) \stackrel{\bowtie}{\rightarrow}(\texttt{mapping}, \texttt{outer}, \texttt{source}) → ⋈ ( mapping , outer , source )
API: ProjectionConcat
mapping (M M M ): i n s t S t r e a m ( T ) \mathrm{inst}_{\mathrm{Stream}(\mathcal{T})} inst Stream ( T )
outer : Boolean
source (S S S ): S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
returns : S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
→ ⋈ ( M , false , S , Γ ) = ⟨ s ⊕ m ∣ m ∈ M ( Γ ⊕ s ) , s ∈ S ⟩ \stackrel{\bowtie}{\rightarrow}(M, \textbf{false}, S, \Gamma) = \langle s \oplus m \mid m \in M(\Gamma \oplus s), s \in S \rangle → ⋈ ( M , false , S , Γ ) = ⟨ s ⊕ m ∣ m ∈ M ( Γ ⊕ s ) , s ∈ S ⟩
ProjectionIndex
Adds an attribute holding each row's ordinal position in the stream (its row
number).
Signature: i n d e x ( key , source ) \mathrm{index}(\texttt{key}, \texttt{source}) index ( key , source )
API: ProjectionIndex
key (k k k ): A \mathcal{A} A
source (S S S ): S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
returns : S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
i n d e x ( k , S ) = ⟨ s i ⊕ { k ↦ i } ∣ s i ∈ S ⟩ \mathrm{index}(k, S) = \langle s_i \oplus \left\{ k \mapsto i \right\} \mid s_i \in S \rangle index ( k , S ) = ⟨ s i ⊕ { k ↦ i } ∣ s i ∈ S ⟩
Selection
Keeps only the rows for which the condition is true: the algebra's WHERE.
Signature: σ ( expression , source ) \sigma(\texttt{expression}, \texttt{source}) σ ( expression , source )
API: Selection
expression (E E E ): i n s t S t r e a m 1 ( V ) \mathrm{inst}_{\mathrm{Stream}_1(\mathcal{V})} inst Stream 1 ( V )
source (S S S ): S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
returns : S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
σ ( E , S , Γ ) = ⟨ s ∣ s ∈ S , E ( Γ ⊕ s ) = ⟨ true ⟩ ⟩ \sigma(E, S, \Gamma) = \langle s \mid s \in S, E(\Gamma \oplus s) = \langle\textbf{true}\rangle \rangle σ ( E , S , Γ ) = ⟨ s ∣ s ∈ S , E ( Γ ⊕ s ) = ⟨ true ⟩⟩
Distinct
Removes duplicate rows. Duplicates are compared on attributes, which may be
the allAttrs symbol * to compare whole rows.
Signature: δ ( attributes , source ) \delta(\texttt{attributes}, \texttt{source}) δ ( attributes , source )
API: Distinct
GroupBy
Partitions rows by their keys and computes one or more aggregates per
partition. Each entry in aggs is an aggregate function paired with the
attribute it writes; the output of each group is its key values concatenated
with its aggregate results.
Signature: γ ( keys , aggs , source ) \gamma(\texttt{keys}, \texttt{aggs}, \texttt{source}) γ ( keys , aggs , source )
API: GroupBy
keys (K K K ):
S e q ( i n s t S t r e a m 1 ( V ) × A ) \mathrm{Seq}(\mathrm{inst}_{\mathrm{Stream}_1(\mathcal{V})} \times \mathcal{A}) Seq ( inst Stream 1 ( V ) × A )
aggs (A A A ):
S e q ( ( S t r e a m ( T ) → V ) × A ) \mathrm{Seq}((\mathrm{Stream}(\mathcal{T}) \rightarrow \mathcal{V}) \times \mathcal{A}) Seq (( Stream ( T ) → V ) × A )
source (S S S ): S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
returns : S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
The helper g r o u p \mathrm{group} group selects the rows belonging to one partition (those
whose key values equal V V V ):
g r o u p ( K , V , S , Γ ) = ⟨ s ∣ s ∈ S , ∀ i : K i ( Γ ⊕ s ) = V i ⟩ \mathrm{group}(K, V, S, \Gamma) = \langle s \mid s \in S, \forall i : K_i(\Gamma \oplus s) = V_i \rangle group ( K , V , S , Γ ) = ⟨ s ∣ s ∈ S , ∀ i : K i ( Γ ⊕ s ) = V i ⟩
γ ( K , A , S , Γ ) = ⟨ { a ↦ k ( Γ ⊕ s ) ∣ ( k , a ) ∈ K } ⊕ { a ↦ f ( g r o u p ( K , ⟨ k ( Γ ⊕ s ) ∣ ( k , _ ) ∈ K ⟩ , S , Γ ) ) ∣ ( f , a ) ∈ A } ∣ s ∈ S ⟩ u n i q u e \begin{aligned}
\gamma(K, A, S, \Gamma) = \langle\ & \{ a \mapsto k(\Gamma \oplus s) \mid (k, a) \in K \}\ \oplus \\
& \{ a \mapsto f(\mathrm{group}(K,\ \langle k(\Gamma \oplus s) \mid (k, \_) \in K \rangle,\ S,\ \Gamma)) \mid (f, a) \in A \} \\
& \mid s \in S\ \rangle_{unique}
\end{aligned} γ ( K , A , S , Γ ) = ⟨ { a ↦ k ( Γ ⊕ s ) ∣ ( k , a ) ∈ K } ⊕ { a ↦ f ( group ( K , ⟨ k ( Γ ⊕ s ) ∣ ( k , _ ) ∈ K ⟩ , S , Γ )) ∣ ( f , a ) ∈ A } ∣ s ∈ S ⟩ u ni q u e
MapFromItem
Wraps each opaque item into a single-attribute row named key, the inverse of
MapToItem . The original item is stored as-is; it is not
reinterpreted as a tuple.
Signature: f r o m I t e m ( key , source ) \mathrm{fromItem}(\texttt{key}, \texttt{source}) fromItem ( key , source )
API: MapFromItem
key (k k k ): A \mathcal{A} A
source (S S S ): S t r e a m ( V ) \mathrm{Stream}(\mathcal{V}) Stream ( V )
returns : S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
f r o m I t e m ( k , S ) = ⟨ { k ↦ s } ∣ s ∈ S ⟩ \mathrm{fromItem}(k, S) = \langle \left\{ k \mapsto s \right\} \mid s \in S \rangle fromItem ( k , S ) = ⟨ { k ↦ s } ∣ s ∈ S ⟩
OrderBy
Sorts the row stream by the given orders (ordering keys with directions).
Schema is unchanged.
Signature: τ ( orders , source ) \tau(\texttt{orders}, \texttt{source}) τ ( orders , source )
API: OrderBy
Recursion
Repeatedly self-joins source, breadth-first, building up paths of length min
to max while condition holds. It backs variable-length graph paths and
recursive CTEs. Each output attribute accumulates an array of values across the
iterations, and condition sees, for every attribute, the array accumulated so
far together with the candidate next value.
Signature:
ϕ ( min , max , condition , source ) \phi(\texttt{min}, \texttt{max}, \texttt{condition}, \texttt{source}) ϕ ( min , max , condition , source )
API: Recursion
min : N \mathbb{N} N
max : N \mathbb{N} N
condition (C C C ): i n s t S t r e a m 1 ( V ) \mathrm{inst}_{\mathrm{Stream}_1(\mathcal{V})} inst Stream 1 ( V )
source (S S S ): S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
returns : S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
Base case, a single step wraps each attribute value in a one-element array:
ϕ ( 0 , 1 , C , S , Γ ) = ⟨ { a ↦ ⟨ s . a ⟩ ∣ a ∈ s } ∣ s ∈ S ⟩ \phi(0, 1, C, S, \Gamma) = \langle \left\{ a \mapsto \langle s.a \rangle \mid a \in s \right\} \mid s \in S \rangle ϕ ( 0 , 1 , C , S , Γ ) = ⟨ { a ↦ ⟨ s . a ⟩ ∣ a ∈ s } ∣ s ∈ S ⟩
Inductive case, extend each accumulated path by one more matching row:
ϕ ( 0 , m a x , C , S , Γ ) = ⟨ { a ↦ a c c . a ∪ ⟨ c u r r . a ⟩ ∣ a ∈ a c c } ∣ c u r r ∈ S , a c c ∈ ϕ ( 0 , m a x − 1 , C , S , Γ ) , C ( Γ ⊕ z i p ( c u r r , a c c ) ) = ⟨ true ⟩ ⟩ \begin{aligned}
\phi(0, \mathrm{max}, C, S, \Gamma) = \langle\ & \{ a \mapsto \mathrm{acc}.a \cup \langle\mathrm{curr}.a\rangle \mid a \in \mathrm{acc} \} \\
& \mid \mathrm{curr} \in S, \\
& \quad \mathrm{acc} \in \phi(0, \mathrm{max} - 1, C, S, \Gamma), \\
& \quad C(\Gamma \oplus \mathrm{zip}(\mathrm{curr}, \mathrm{acc})) = \langle\textbf{true}\rangle\ \rangle
\end{aligned} ϕ ( 0 , max , C , S , Γ ) = ⟨ { a ↦ acc . a ∪ ⟨ curr . a ⟩ ∣ a ∈ acc } ∣ curr ∈ S , acc ∈ ϕ ( 0 , max − 1 , C , S , Γ ) , C ( Γ ⊕ zip ( curr , acc )) = ⟨ true ⟩ ⟩
Finally, keep only paths of at least min length:
ϕ ( m i n , m a x , C , S , Γ ) = ⟨ p ∣ p ∈ ϕ ( 0 , m a x , C , S , Γ ) , ∀ a ∈ p : ∣ p . a ∣ ≥ m i n ⟩ \phi(\mathrm{min}, \mathrm{max}, C, S, \Gamma) = \langle p \mid p \in \phi(0, \mathrm{max}, C, S, \Gamma), \forall a \in p: |p.a| \geq \mathrm{min} \rangle ϕ ( min , max , C , S , Γ ) = ⟨ p ∣ p ∈ ϕ ( 0 , max , C , S , Γ ) , ∀ a ∈ p : ∣ p . a ∣ ≥ min ⟩
TupleSource
A named source that emits rows, for example a registered relational table. Its
schema is generally not known until planning resolves it.
Signature: name \textbf{name} name
API: TupleSource
TupleFnSource
Like TupleSource , but the rows come from calling a function
with parameters.
Signature: name ( impl , params ) \textbf{name}(\texttt{impl}, \texttt{params}) name ( impl , params )
API: TupleFnSource
impl (i i i ):
S e q ( S t r e a m 1 ( V ) ) → S t r e a m ( T ) \mathrm{Seq}(\mathrm{Stream}_1(\mathcal{V})) \rightarrow \mathrm{Stream}(\mathcal{T}) Seq ( Stream 1 ( V )) → Stream ( T )
params (A A A ): S e q ( S t r e a m 1 ( V ) ) \mathrm{Seq}(\mathrm{Stream}_1(\mathcal{V})) Seq ( Stream 1 ( V ))
returns : S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
n a m e ( i , A ) = i ( A ) \mathrm{name}(i, A) = i(A) name ( i , A ) = i ( A )
Tuple operators: XQuery
These two operators are provided by the XQuery package, not the core. They
demonstrate that the algebra is extensible.
Operator Notation Result schema ProjectionSize s i z e ( key , source ) \mathrm{size}(\texttt{key}, \texttt{source}) size ( key , source ) source ⊕ ( key ) \texttt{source} \oplus (\texttt{key}) source ⊕ ( key ) TreeJoin t r e e J o i n ( expr , source ) \mathrm{treeJoin}(\texttt{expr}, \texttt{source}) treeJoin ( expr , source ) source ⊕ ( fs.dot , fs.position , fs.last ) \texttt{source} \oplus (\texttt{fs.dot}, \texttt{fs.position}, \texttt{fs.last}) source ⊕ ( fs.dot , fs.position , fs.last )
ProjectionSize
Adds an attribute holding the total number of rows in the stream. XQuery needs
this to expose $fs:last during path navigation.
Signature: s i z e ( key , source ) \mathrm{size}(\texttt{key}, \texttt{source}) size ( key , source )
API:
ProjectionSize
key (k k k ): A \mathcal{A} A
source (S S S ): S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
returns : S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
s i z e ( k , S ) = ⟨ s ⊕ { k ↦ ∣ S ∣ } ∣ s ∈ S ⟩ \mathrm{size}(k, S) = \langle s \oplus \left\{ k \mapsto |S| \right\} \mid s \in S \rangle size ( k , S ) = ⟨ s ⊕ { k ↦ ∣ S ∣ } ∣ s ∈ S ⟩
TreeJoin
Implements an XQuery path step such as a/b/c. For each source row it evaluates
expr and, for every produced item, emits a row carrying the XQuery focus: the
current item ($fs:dot), its position ($fs:position), and the total count
($fs:last). It rolls ProjectionConcat ,
ProjectionIndex , and ProjectionSize
into one, but unlike ProjectionConcat , its expr is a
Calculation , not a tuple operator.
Signature: t r e e J o i n ( expr , source ) \mathrm{treeJoin}(\texttt{expr}, \texttt{source}) treeJoin ( expr , source )
API: TreeJoin
expr (E E E ): i n s t S t r e a m ( V ) \mathrm{inst}_{\mathrm{Stream}(\mathcal{V})} inst Stream ( V )
source (S S S ): S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
returns : S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
t r e e J o i n ( E , S , Γ ) = ⟨ s i ⊕ { ⟨ f s , d o t ⟩ ↦ e , ⟨ f s , p o s i t i o n ⟩ ↦ i , ⟨ f s , l a s t ⟩ ↦ ∣ t r e e J o i n ( E , S , Γ ) ∣ } ∣ s i ∈ S , e ∈ E ( Γ ⊕ s i ) ⟩ \begin{aligned}
\mathrm{treeJoin}(E, S, \Gamma) = \langle\ & s_i \oplus \{ \\
& \quad \langle\mathrm{fs}, \mathrm{dot}\rangle \mapsto e,\ \\
& \quad \langle\mathrm{fs}, \mathrm{position}\rangle \mapsto i,\ \\
& \quad \langle\mathrm{fs}, \mathrm{last}\rangle \mapsto |\mathrm{treeJoin}(E, S, \Gamma)| \\
& \} \mid s_i \in S, e \in E(\Gamma \oplus s_i)\ \rangle
\end{aligned} treeJoin ( E , S , Γ ) = ⟨ s i ⊕ { ⟨ fs , dot ⟩ ↦ e , ⟨ fs , position ⟩ ↦ i , ⟨ fs , last ⟩ ↦ ∣ treeJoin ( E , S , Γ ) ∣ } ∣ s i ∈ S , e ∈ E ( Γ ⊕ s i ) ⟩
Tuple operators: Optimizer
These operators are not part of the theoretical algebra ; a plan is complete
and correct without them. They exist only to give the
optimizer better targets, enabling substantial speedups.
Two of them enable secondary indices ; the
third is a faster variant of Recursion .
Operator Notation Result schema IndexScan i n d e x S c a n ( name , access , fromItemKey ) \mathrm{indexScan}(\texttt{name}, \texttt{access}, \texttt{fromItemKey}) indexScan ( name , access , fromItemKey ) unknown IndexedRecursion → ϕ ( min , max , mapping , source ) \stackrel{\phi}{\rightarrow}(\texttt{min}, \texttt{max}, \texttt{mapping}, \texttt{source}) → ϕ ( min , max , mapping , source ) source \texttt{source} source BidirectionalRecursion ↔ ϕ ( min , max , mappingFwd , mappingRev , target , source ) \stackrel{\phi}{\leftrightarrow}(\texttt{min}, \texttt{max}, \texttt{mappingFwd}, \texttt{mappingRev}, \texttt{target}, \texttt{source}) ↔ ϕ ( min , max , mappingFwd , mappingRev , target , source ) source ⊕ target \texttt{source} \oplus \texttt{target} source ⊕ target
IndexScan
Replaces a filtered TupleSource (or an
ItemSource paired with a MapFromItem ) with a
lookup into a registered index. Instead of scanning the whole source, it holds
an access Calculation that feeds the matching values
straight into the underlying index structure. When it stands in for the
item-source case, fromItemKey carries the MapFromItem key so
the result is still a single-attribute row stream.
Signature:
API: IndexScan
i n d e x S c a n ( name , access , fromItemKey ) \mathrm{indexScan}(\texttt{name}, \texttt{access}, \texttt{fromItemKey}) indexScan ( name , access , fromItemKey )
name : the indexed source's name
access : C a l c u l a t i o n \mathrm{Calculation} Calculation , the index accessor
fromItemKey : A \mathcal{A} A (optional, only for the
ItemSource case)
returns : S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
IndexedRecursion
A variant of Recursion that behaves like a recursive
depend-join : instead of self-joining a fixed source, it
re-evaluates mapping against each accumulated path, so every step can be
driven by an index. This is what makes indexed graph traversal possible.
Signature:
→ ϕ ( min , max , mapping , source ) \stackrel{\phi}{\rightarrow}(\texttt{min}, \texttt{max}, \texttt{mapping}, \texttt{source}) → ϕ ( min , max , mapping , source )
API: IndexedRecursion
min : N \mathbb{N} N
max : N \mathbb{N} N
mapping (M M M ): i n s t S t r e a m ( T ) \mathrm{inst}_{\mathrm{Stream}(\mathcal{T})} inst Stream ( T )
source (S S S ): S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
returns : S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
Base case, a single step wraps each attribute value in a one-element array:
→ ϕ ( 0 , 1 , M , S , Γ ) = ⟨ { a ↦ ⟨ s . a ⟩ ∣ a ∈ s } ∣ s ∈ S ⟩ \stackrel{\phi}{\rightarrow}(0, 1, M, S, \Gamma) = \langle \left\{ a \mapsto \langle s.a \rangle \mid a \in s \right\} \mid s \in S \rangle → ϕ ( 0 , 1 , M , S , Γ ) = ⟨ { a ↦ ⟨ s . a ⟩ ∣ a ∈ s } ∣ s ∈ S ⟩
Inductive case, extend each accumulated path by re-instantiating the mapping
against it:
→ ϕ ( 0 , m a x , M , S , Γ ) = ⟨ { a ↦ a c c . a ∪ ⟨ c u r r . a ⟩ ∣ a ∈ a c c } ∣ a c c ∈ → ϕ ( 0 , m a x − 1 , M , S , Γ ) , c u r r ∈ M ( Γ ⊕ a c c ) ⟩ \begin{aligned}
\stackrel{\phi}{\rightarrow}(0, \mathrm{max}, M, S, \Gamma) = \langle\ & \{ a \mapsto \mathrm{acc}.a \cup \langle\mathrm{curr}.a\rangle \mid a \in \mathrm{acc} \} \\
& \mid \mathrm{acc} \in \stackrel{\phi}{\rightarrow}(0, \mathrm{max} - 1, M, S, \Gamma), \\
& \quad \mathrm{curr} \in M(\Gamma \oplus \mathrm{acc})\ \rangle
\end{aligned} → ϕ ( 0 , max , M , S , Γ ) = ⟨ { a ↦ acc . a ∪ ⟨ curr . a ⟩ ∣ a ∈ acc } ∣ acc ∈ → ϕ ( 0 , max − 1 , M , S , Γ ) , curr ∈ M ( Γ ⊕ acc ) ⟩
Finally, keep only paths of at least min length:
→ ϕ ( m i n , m a x , M , S , Γ ) = ⟨ p ∣ p ∈ → ϕ ( 0 , m a x , M , S , Γ ) , ∀ a ∈ p : ∣ p . a ∣ ≥ m i n ⟩ \stackrel{\phi}{\rightarrow}(\mathrm{min}, \mathrm{max}, M, S, \Gamma) = \langle p \mid p \in \stackrel{\phi}{\rightarrow}(0, \mathrm{max}, M, S, \Gamma), \forall a \in p: |p.a| \geq \mathrm{min} \rangle → ϕ ( min , max , M , S , Γ ) = ⟨ p ∣ p ∈ → ϕ ( 0 , max , M , S , Γ ) , ∀ a ∈ p : ∣ p . a ∣ ≥ min ⟩
BidirectionalRecursion
Searches a recursive path from both ends at once, expanding mappingFwd from
the source side and mappingRev from the target side until the two
frontiers meet. It is more work to set up than
IndexedRecursion , but offers large asymptotic
improvements in both time and memory. Its result combines the schemas of both
ends, source ⊕ target \texttt{source} \oplus \texttt{target} source ⊕ target .
Signature:
↔ ϕ ( min , max , mappingFwd , mappingRev , target , source ) \stackrel{\phi}{\leftrightarrow}(\texttt{min}, \texttt{max}, \texttt{mappingFwd}, \texttt{mappingRev}, \texttt{target}, \texttt{source}) ↔ ϕ ( min , max , mappingFwd , mappingRev , target , source )
API:
BidirectionalRecursion
min : N \mathbb{N} N
max : N \mathbb{N} N
mappingFwd : i n s t S t r e a m ( T ) \mathrm{inst}_{\mathrm{Stream}(\mathcal{T})} inst Stream ( T )
mappingRev : i n s t S t r e a m ( T ) \mathrm{inst}_{\mathrm{Stream}(\mathcal{T})} inst Stream ( T )
target : S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
source : S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
returns : S t r e a m ( T ) \mathrm{Stream}(\mathcal{T}) Stream ( T )
Universal operators
Universal operators accept either tuples or items.
Operator Notation NullSource □ \square □ Limit l i m i t ( offset , limit , source ) \mathrm{limit}(\texttt{offset}, \texttt{limit}, \texttt{source}) limit ( offset , limit , source ) Set Union ∪ ( left , right ) \cup(\texttt{left}, \texttt{right}) ∪ ( left , right ) Intersection ∩ ( left , right ) \cap(\texttt{left}, \texttt{right}) ∩ ( left , right ) Difference ∖ ( left , right ) \setminus(\texttt{left}, \texttt{right}) ∖ ( left , right )
NullSource
Emits exactly one empty row. It gives constant queries like SELECT 1 AS one
something to project from.
Signature: □ \square □
API: NullSource
returns : S t r e a m 1 ( V ∪ T ) \mathrm{Stream}_1(\mathcal{V} \cup \mathcal{T}) Stream 1 ( V ∪ T )
□ = ⟨ ∅ ⟩ \square = \langle \varnothing \rangle □ = ⟨ ∅ ⟩
Limit
Skips the first offset results, then passes through at most limit of them:
OFFSET plus LIMIT.
Signature: l i m i t ( offset , limit , source ) \mathrm{limit}(\texttt{offset}, \texttt{limit}, \texttt{source}) limit ( offset , limit , source )
API: Limit
offset (o o o ): N \mathbb{N} N
limit (l l l ): N \mathbb{N} N
source (S S S ): S t r e a m ( V ∪ T ) \mathrm{Stream}(\mathcal{V} \cup \mathcal{T}) Stream ( V ∪ T )
returns : S t r e a m ( V ∪ T ) \mathrm{Stream}(\mathcal{V} \cup \mathcal{T}) Stream ( V ∪ T )
l i m i t ( o , l , S ) = ⟨ s i ∣ s i ∈ S , o < i ≤ o + l ⟩ \mathrm{limit}(o, l, S) = \langle s_i \mid s_i \in S, o < i \leq o + l \rangle limit ( o , l , S ) = ⟨ s i ∣ s i ∈ S , o < i ≤ o + l ⟩
Set operators
Union, Intersection, and Difference are the standard set operations over
two streams. Each takes left (L L L ) and right (R R R ) of type
S t r e a m ( V ∪ T ) \mathrm{Stream}(\mathcal{V} \cup \mathcal{T}) Stream ( V ∪ T ) and returns the same type.
API: Union ,
Intersection ,
Difference
∪ ( L , R ) = L ∪ R \cup(L, R) = L \cup R ∪ ( L , R ) = L ∪ R
∩ ( L , R ) = ⟨ x ∣ x ∈ R ∧ x ∈ L ⟩ \cap(L, R) = \langle x \mid x \in R \wedge x \in L \rangle ∩ ( L , R ) = ⟨ x ∣ x ∈ R ∧ x ∈ L ⟩
∖ ( L , R ) = ⟨ x ∣ x ∈ L ∧ x ∉ R ⟩ \setminus(L, R) = \langle x \mid x \in L \wedge x \notin R \rangle ∖ ( L , R ) = ⟨ x ∣ x ∈ L ∧ x ∈ / R ⟩