Class SqlToRelConverter.AggConverter

java.lang.Object
org.apache.calcite.sql2rel.SqlToRelConverter.AggConverter
All Implemented Interfaces:
org.apache.calcite.sql.util.SqlVisitor<Void>
Enclosing class:
SqlToRelConverter

protected class SqlToRelConverter.AggConverter extends Object implements org.apache.calcite.sql.util.SqlVisitor<Void>
Converts expressions to aggregates.

Consider the expression

SELECT deptno, SUM(2 * sal) FROM emp GROUP BY deptno

Then:

  • groupExprs = {SqlIdentifier(deptno)}
  • convertedInputExprs = {RexInputRef(deptno), 2 * RefInputRef(sal)}
  • inputRefs = {RefInputRef(#0), RexInputRef(#1)}
  • aggCalls = {AggCall(SUM, {1})}
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final @Nullable org.apache.calcite.sql.validate.AggregatingSelectScope
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    AggConverter(SqlToRelConverter.Blackboard bb, org.apache.calcite.sql.SqlSelect select)
    Creates an AggConverter.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    addGroupExpr(org.apache.calcite.sql.SqlNode expr)
     
    List<org.apache.calcite.rel.core.AggregateCall>
     
    List<org.apache.calcite.util.Pair<org.apache.calcite.rex.RexNode,@Nullable String>>
     
    org.apache.calcite.rel.type.RelDataTypeFactory
     
    @Nullable org.apache.calcite.rex.RexNode
    lookupAggregates(org.apache.calcite.sql.SqlCall call)
     
    int
    lookupGroupExpr(org.apache.calcite.sql.SqlNode expr)
    If an expression is structurally identical to one of the group-by expressions, returns a reference to the expression, otherwise returns null.
    visit(org.apache.calcite.sql.SqlCall call)
     
    visit(org.apache.calcite.sql.SqlDataTypeSpec type)
     
    visit(org.apache.calcite.sql.SqlDynamicParam param)
     
    visit(org.apache.calcite.sql.SqlIdentifier id)
     
    visit(org.apache.calcite.sql.SqlIntervalQualifier intervalQualifier)
     
    visit(org.apache.calcite.sql.SqlLiteral lit)
     
    visit(org.apache.calcite.sql.SqlNodeList nodeList)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.calcite.sql.util.SqlVisitor

    visitNode
  • Field Details

    • aggregatingSelectScope

      public final @Nullable org.apache.calcite.sql.validate.AggregatingSelectScope aggregatingSelectScope
  • Constructor Details

    • AggConverter

      public AggConverter(SqlToRelConverter.Blackboard bb, org.apache.calcite.sql.SqlSelect select)
      Creates an AggConverter.

      The select parameter provides enough context to name aggregate calls which are top-level select list items.

      Parameters:
      bb - Blackboard
      select - Query being translated; provides context to give
  • Method Details

    • addGroupExpr

      public int addGroupExpr(org.apache.calcite.sql.SqlNode expr)
    • visit

      public Void visit(org.apache.calcite.sql.SqlIdentifier id)
      Specified by:
      visit in interface org.apache.calcite.sql.util.SqlVisitor<Void>
    • visit

      public Void visit(org.apache.calcite.sql.SqlNodeList nodeList)
      Specified by:
      visit in interface org.apache.calcite.sql.util.SqlVisitor<Void>
    • visit

      public Void visit(org.apache.calcite.sql.SqlLiteral lit)
      Specified by:
      visit in interface org.apache.calcite.sql.util.SqlVisitor<Void>
    • visit

      public Void visit(org.apache.calcite.sql.SqlDataTypeSpec type)
      Specified by:
      visit in interface org.apache.calcite.sql.util.SqlVisitor<Void>
    • visit

      public Void visit(org.apache.calcite.sql.SqlDynamicParam param)
      Specified by:
      visit in interface org.apache.calcite.sql.util.SqlVisitor<Void>
    • visit

      public Void visit(org.apache.calcite.sql.SqlIntervalQualifier intervalQualifier)
      Specified by:
      visit in interface org.apache.calcite.sql.util.SqlVisitor<Void>
    • visit

      public Void visit(org.apache.calcite.sql.SqlCall call)
      Specified by:
      visit in interface org.apache.calcite.sql.util.SqlVisitor<Void>
    • lookupGroupExpr

      public int lookupGroupExpr(org.apache.calcite.sql.SqlNode expr)
      If an expression is structurally identical to one of the group-by expressions, returns a reference to the expression, otherwise returns null.
    • lookupAggregates

      public @Nullable org.apache.calcite.rex.RexNode lookupAggregates(org.apache.calcite.sql.SqlCall call)
    • getPreExprs

      public List<org.apache.calcite.util.Pair<org.apache.calcite.rex.RexNode,@Nullable String>> getPreExprs()
    • getAggCalls

      public List<org.apache.calcite.rel.core.AggregateCall> getAggCalls()
    • getTypeFactory

      public org.apache.calcite.rel.type.RelDataTypeFactory getTypeFactory()