- Record Components:
valueColumn- the column whose values fill the new pivot cells; must not be blankkeyColumn- the column whose distinct values become new column headers; must not be blankgroupKeys- thePERgrouping columns; empty means one global group; must not be nullinput- the source relation; must not be nulllocation- the source location of this node; never null
- All Implemented Interfaces:
RelNode
The PIVOT operator groups rows by the optional groupKeys() (or
treats the whole relation as one group when groupKeys() is empty),
finds the distinct values of keyColumn(), and emits one output row
per group. Each distinct key value becomes a new column whose cell value is
taken from valueColumn().
Because the output schema depends on the runtime data (the distinct key
values are not known at parse time), PIVOT always produces an open,
schema-on-read Schema.open() as its output schema. Column names in
the output are the string representations of the distinct key values.
Surface syntax:
PIVOT revenue BY month PER region (MonthlySales) PIVOT amount BY category (Transactions)
PIVOT is a blocking operator (MaterializationMode.BAG) — it must
consume the entire input before it can emit any output, since it needs to
discover the full set of distinct key values first. It is never pushed down
to a source.
-
Constructor Summary
ConstructorsConstructorDescriptionConvenience constructor for tests:SourceLocation.UNKNOWN.PivotNode(String valueColumn, String keyColumn, List<String> groupKeys, RelNode input, SourceLocation location) Creates an instance of aPivotNoderecord class. -
Method Summary
Modifier and TypeMethodDescription<R> Raccept(RelNodeVisitor<R> visitor) final booleanIndicates whether some other object is "equal to" this one.Returns the value of thegroupKeysrecord component.final inthashCode()Returns a hash code value for this object.input()Returns the value of theinputrecord component.Returns the value of thekeyColumnrecord component.location()Returns the value of thelocationrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thevalueColumnrecord component.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
-
PivotNode
public PivotNode(String valueColumn, String keyColumn, List<String> groupKeys, RelNode input, SourceLocation location) Creates an instance of aPivotNoderecord class.- Parameters:
valueColumn- the value for thevalueColumnrecord componentkeyColumn- the value for thekeyColumnrecord componentgroupKeys- the value for thegroupKeysrecord componentinput- the value for theinputrecord componentlocation- the value for thelocationrecord component
-
PivotNode
Convenience constructor for tests: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. All components in this record class are compared withObjects::equals(Object,Object). -
valueColumn
Returns the value of thevalueColumnrecord component.- Returns:
- the value of the
valueColumnrecord component
-
keyColumn
Returns the value of thekeyColumnrecord component.- Returns:
- the value of the
keyColumnrecord component
-
groupKeys
Returns the value of thegroupKeysrecord component.- Returns:
- the value of the
groupKeysrecord component
-
input
Returns the value of theinputrecord component.- Returns:
- the value of the
inputrecord component
-
location
Returns the value of thelocationrecord component.
-