java.lang.Object
java.lang.Record
com.darkcollective.relix.ast.GroupingKey
- Record Components:
expression- the expression the rows are grouped by; never nullalias- the optional output column name
A single grouping key of an aggregation (
γ): the Operand
expression the rows are grouped by, with an optional alias for the output
column.
The expression is a full scalar expression, not merely a column reference,
so a group may be formed over a derived value — e.g.
γ YEAR(occurred_at) → yr, COUNT(id) → n (Events) groups by the parsed
year. The common case γ customer_id, SUM(amount) (Orders) is simply a
grouping over an AttributeOperand.
Examples:
- Bare column:
customer_id - Aliased column:
customer_id → cust - Derived key:
DATE_TRUNC('day', ts) → day
-
Constructor Summary
ConstructorsConstructorDescriptionGroupingKey(Operand expression, Optional<String> alias) Creates an instance of aGroupingKeyrecord class. -
Method Summary
Modifier and TypeMethodDescriptionalias()Returns the value of thealiasrecord component.static GroupingKeyA grouping key over an arbitrary expression, with an alias.static GroupingKeyA grouping key over a bare column, without an alias.The input column name this key groups by, iff the key is a bare attribute reference (the alias, which only renames the output, is irrelevant here); empty for any derived expression.static List<GroupingKey> Wraps a list of bare column names as grouping keys (order preserved).final booleanIndicates whether some other object is "equal to" this one.Returns the value of theexpressionrecord component.final inthashCode()Returns a hash code value for this object.booleanWhether this key is a bare, unaliased column reference — the classic grouping form whose output column equals the input column.static GroupingKeyA grouping key over an arbitrary expression, without an alias.The name of the output column this grouping key produces: thealias()when present, otherwise the (unqualified) attribute name for a bare column, the function name for a function call, or the syntheticgroupfor any other expression.plainColumns(List<GroupingKey> keys) The input columns ofkeys, iff every key is a bare attribute reference; empty if any key is a derived expression.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
GroupingKey
Creates an instance of aGroupingKeyrecord class.- Parameters:
expression- the value for theexpressionrecord componentalias- the value for thealiasrecord component
-
-
Method Details
-
column
A grouping key over a bare column, without an alias. -
of
A grouping key over an arbitrary expression, without an alias. -
aliased
A grouping key over an arbitrary expression, with an alias. -
columns
Wraps a list of bare column names as grouping keys (order preserved). -
outputName
The name of the output column this grouping key produces: thealias()when present, otherwise the (unqualified) attribute name for a bare column, the function name for a function call, or the syntheticgroupfor any other expression. Schema inference and the optimizer use this so the produced column name is consistent everywhere.- Returns:
- the output column name; never blank
-
columnName
The input column name this key groups by, iff the key is a bare attribute reference (the alias, which only renames the output, is irrelevant here); empty for any derived expression. Statistics lookups, streaming-γ gating, and SQLGROUP BYpushdown use this to distinguish a plain column from a computed key.- Returns:
- the unqualified column name, or empty for an expression key
-
isPlainColumn
public boolean isPlainColumn()Whether this key is a bare, unaliased column reference — the classic grouping form whose output column equals the input column.- Returns:
trueif the key is an unaliasedAttributeOperand
-
plainColumns
The input columns ofkeys, iff every key is a bare attribute reference; empty if any key is a derived expression. Used where a grouping can only be reasoned about (ordering-based streaming, GROUP BY pushdown) when it is entirely over plain columns.- Parameters:
keys- the grouping keys; must not be null- Returns:
- the ordered column names, or empty if any key is an expression
-
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). -
expression
Returns the value of theexpressionrecord component.- Returns:
- the value of the
expressionrecord component
-
alias
Returns the value of thealiasrecord component.- Returns:
- the value of the
aliasrecord component
-