Package org.apache.calcite.sql2rel
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 @Nullable org.apache.calcite.sql.validate.AggregatingSelectScope
aggregatingSelectScope
-
Constructor Summary
Constructors Constructor Description AggConverter(SqlToRelConverter.Blackboard bb, org.apache.calcite.sql.SqlSelect select)
Creates an AggConverter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
addGroupExpr(org.apache.calcite.sql.SqlNode expr)
List<org.apache.calcite.rel.core.AggregateCall>
getAggCalls()
List<org.apache.calcite.util.Pair<org.apache.calcite.rex.RexNode,@Nullable String>>
getPreExprs()
org.apache.calcite.rel.type.RelDataTypeFactory
getTypeFactory()
@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.Void
visit(org.apache.calcite.sql.SqlCall call)
Void
visit(org.apache.calcite.sql.SqlDataTypeSpec type)
Void
visit(org.apache.calcite.sql.SqlDynamicParam param)
Void
visit(org.apache.calcite.sql.SqlIdentifier id)
Void
visit(org.apache.calcite.sql.SqlIntervalQualifier intervalQualifier)
Void
visit(org.apache.calcite.sql.SqlLiteral lit)
Void
visit(org.apache.calcite.sql.SqlNodeList nodeList)
-
-
-
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
- Blackboardselect
- 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 interfaceorg.apache.calcite.sql.util.SqlVisitor<Void>
-
visit
public Void visit(org.apache.calcite.sql.SqlNodeList nodeList)
- Specified by:
visit
in interfaceorg.apache.calcite.sql.util.SqlVisitor<Void>
-
visit
public Void visit(org.apache.calcite.sql.SqlLiteral lit)
- Specified by:
visit
in interfaceorg.apache.calcite.sql.util.SqlVisitor<Void>
-
visit
public Void visit(org.apache.calcite.sql.SqlDataTypeSpec type)
- Specified by:
visit
in interfaceorg.apache.calcite.sql.util.SqlVisitor<Void>
-
visit
public Void visit(org.apache.calcite.sql.SqlDynamicParam param)
- Specified by:
visit
in interfaceorg.apache.calcite.sql.util.SqlVisitor<Void>
-
visit
public Void visit(org.apache.calcite.sql.SqlIntervalQualifier intervalQualifier)
- Specified by:
visit
in interfaceorg.apache.calcite.sql.util.SqlVisitor<Void>
-
visit
public Void visit(org.apache.calcite.sql.SqlCall call)
- Specified by:
visit
in interfaceorg.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()
-
-