Class 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 Detail

      • aggregatingSelectScope

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

      • 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 Detail

      • 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()