java.lang.Object
java.lang.Record
com.darkcollective.relix.ast.UnnestNode
- Record Components:
column- the name of the array column to unnest; must not be blankouter- whether to preserve input rows whose array is empty/missingordinalityColumn- the name of the appended 1-based index column, or empty for no ordinality; never nullinput- the source relation; must not be nulllocation- the source location of this node; never null
- All Implemented Interfaces:
RelNode
public record UnnestNode(String column, boolean outer, Optional<String> ordinalityColumn, RelNode input, SourceLocation location)
extends Record
implements RelNode
Unnest (μ) — explodes an array-valued column into one row per element,
carrying the other columns through (≈ SQL
LATERAL UNNEST, Mongo
$unwind). This is the bridge that makes nested data relationally
queryable.
For each input row, the value of column() is treated as an array;
the operator emits one output row per element with column bound to that
element (and the remaining columns unchanged). The outer() flag selects
the behaviour when the value is an empty array, NULL, missing, or not an
array:
- inner (
outer == false) — emit no rows (drop the input row); - outer (
outer == true) — emit a single row withcolumnbound toNULL.
When ordinalityColumn() is present (the SQL WITH ORDINALITY
variant — μ items WITH ORDINALITY pos), an extra NUMBER column of
that name is appended carrying each element's 1-based position in
its array. In the outer no-element case the ordinality is NULL
alongside the NULL element.
Example: μ items (Orders) — one row per element of items;
μ items WITH ORDINALITY pos (Orders) — likewise, plus a pos column
numbering the elements from 1.
-
Constructor Summary
ConstructorsConstructorDescriptionUnnestNode(String column, boolean outer, RelNode input) Convenience constructor for tests: no ordinality,SourceLocation.UNKNOWN.UnnestNode(String column, boolean outer, Optional<String> ordinalityColumn, RelNode input, SourceLocation location) Creates an instance of aUnnestNoderecord class.UnnestNode(String column, RelNode input) Convenience constructor for tests: inner unnest, no ordinality,SourceLocation.UNKNOWN. -
Method Summary
Modifier and TypeMethodDescription<R> Raccept(RelNodeVisitor<R> visitor) column()Returns the value of thecolumnrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.input()Returns the value of theinputrecord component.location()Returns the value of thelocationrecord component.Returns the value of theordinalityColumnrecord component.booleanouter()Returns the value of theouterrecord component.final StringtoString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.darkcollective.relix.ast.RelNode
children, mapChildren, materializationMode, prettyPrint
-
Constructor Details
-
UnnestNode
public UnnestNode(String column, boolean outer, Optional<String> ordinalityColumn, RelNode input, SourceLocation location) Creates an instance of aUnnestNoderecord class.- Parameters:
column- the value for thecolumnrecord componentouter- the value for theouterrecord componentordinalityColumn- the value for theordinalityColumnrecord componentinput- the value for theinputrecord componentlocation- the value for thelocationrecord component
-
UnnestNode
Convenience constructor for tests: inner unnest, no ordinality,SourceLocation.UNKNOWN. -
UnnestNode
Convenience constructor for tests: no ordinality,SourceLocation.UNKNOWN.
-
-
Method Details
-
accept
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
column
Returns the value of thecolumnrecord component.- Returns:
- the value of the
columnrecord component
-
outer
public boolean outer()Returns the value of theouterrecord component.- Returns:
- the value of the
outerrecord component
-
ordinalityColumn
Returns the value of theordinalityColumnrecord component.- Returns:
- the value of the
ordinalityColumnrecord component
-
input
Returns the value of theinputrecord component.- Returns:
- the value of the
inputrecord component
-
location
Returns the value of thelocationrecord component.
-