Package org.apache.calcite.sql2rel
Class SqlToRelConverter.Blackboard
java.lang.Object
org.apache.calcite.sql2rel.SqlToRelConverter.Blackboard
- All Implemented Interfaces:
SqlVisitor<RexNode>,InitializerContext,SqlRexContext
- Enclosing class:
SqlToRelConverter
protected class SqlToRelConverter.Blackboard
extends Object
implements SqlRexContext, SqlVisitor<RexNode>, InitializerContext
Workspace for translating an individual SELECT statement (or sub-SELECT).
-
Field Summary
FieldsModifier and TypeFieldDescription@Nullable RelNodefinal SqlValidatorScopeCollection ofRelNodeobjects which correspond to a SELECT statement. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBlackboard(@Nullable SqlValidatorScope scope, @Nullable Map<String, RexNode> nameToNodeMap, boolean top) Creates a Blackboard. -
Method Summary
Modifier and TypeMethodDescriptionconvertExpression(SqlNode expr) convertInterval(SqlIntervalQualifier intervalQualifier) convertLiteral(SqlLiteral literal) Converts a literal.convertSortExpression(SqlNode expr, RelFieldCollation.Direction direction, RelFieldCollation.NullDirection nullDirection) Deprecated.voidflatten(List<RelNode> rels, int systemFieldCount, int[] start, BiConsumer<RelNode, Integer> relOffsetList) Returns the factory which supplies default values for INSERT, UPDATE, and NEW.Returns theRexBuilderto use to createRexNodeobjects.getSubQueryExpr(SqlCall call) Returns the expression used to access a given IN or EXISTSsub-query.Returns the type factory.Returns the validator.booleanIf the operator call occurs in an aggregate query, returns whether there are empty groups in the GROUP BY clause.@Nullable SqlNodelookupMeasure(SqlIdentifier identifier) register(RelNode rel, JoinRelType joinType) register(RelNode rel, JoinRelType joinType, @Nullable List<RexNode> leftKeys) Registers a relational expression.reRegister(RelNode root) Re-register theregisteredwith given root node and return the new root node.root()scope()Deprecated.voidsetDataset(@Nullable String datasetName) Notifies this Blackboard that the root just set usingsetRoot(RelNode, boolean)was derived using dataset substitution.voidsetPatternVarRef(boolean isVarRef) voidSets a new root relational expression, as the translation process backs its way further up the tree.validateExpression(RelDataType rowType, SqlNode expr) Validate the expression with a base table row type.Visits a call to aSqlOperator.visit(SqlDataTypeSpec type) Visits a datatype specification.visit(SqlDynamicParam param) Visits a dynamic parameter.visit(SqlIdentifier id) Visits an identifier.visit(SqlIntervalQualifier intervalQualifier) Visits an interval qualifier.visit(SqlLiteral literal) Visits a literal.visit(SqlNodeList nodeList) Visits a list ofSqlNodeobjects.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.calcite.sql2rel.InitializerContext
parseExpressionMethods inherited from interface org.apache.calcite.sql.util.SqlVisitor
visitAll, visitNode
-
Field Details
-
scope
Collection ofRelNodeobjects which correspond to a SELECT statement. -
root
-
-
Constructor Details
-
Blackboard
protected Blackboard(@Nullable SqlValidatorScope scope, @Nullable Map<String, RexNode> nameToNodeMap, boolean top) Creates a Blackboard.- Parameters:
scope- Name-resolution scope for expressions validated within this query. Can be null if this Blackboard is for a leaf node, saynameToNodeMap- Map which translates the expression to map a given parameter into, if translating expressions; null otherwisetop- Whether this is the root of the query
-
-
Method Details
-
root
-
scope
Deprecated. -
setPatternVarRef
public void setPatternVarRef(boolean isVarRef) -
register
-
register
Registers a relational expression.- Parameters:
rel- Relational expressionjoinType- Join typeleftKeys- LHS of IN clause, or null for expressions other than IN- Returns:
- Expression with which to refer to the row (or partial row) coming from this relational expression's side of the join
-
reRegister
Re-register theregisteredwith given root node and return the new root node.- Parameters:
root- The given root, never leaf- Returns:
- new root after the registration
-
setRoot
Sets a new root relational expression, as the translation process backs its way further up the tree.- Parameters:
root- New root relational expressionleaf- Whether the relational expression is a leaf, that is, derived from an atomic relational expression such as a table name in the from clause, or the projection on top of a select-sub-query. In particular, relational expressions derived from JOIN operators are not leaves, but set expressions are.
-
setDataset
Notifies this Blackboard that the root just set usingsetRoot(RelNode, boolean)was derived using dataset substitution.The default implementation is not interested in such notifications, and does nothing.
- Parameters:
datasetName- Dataset name
-
flatten
public void flatten(List<RelNode> rels, int systemFieldCount, int[] start, BiConsumer<RelNode, Integer> relOffsetList) -
convertExpression
Description copied from interface:SqlRexContext- Specified by:
convertExpressionin interfaceInitializerContext- Specified by:
convertExpressionin interfaceSqlRexContext- Parameters:
expr- Expression to translate- Returns:
- Converted expression
-
convertSortExpression
@Deprecated public RexFieldCollation convertSortExpression(SqlNode expr, RelFieldCollation.Direction direction, RelFieldCollation.NullDirection nullDirection) Deprecated.Converts an item in an ORDER BY clause inside a window (OVER) clause, extracting DESC, NULLS LAST and NULLS FIRST flags first. -
hasEmptyGroup
public boolean hasEmptyGroup()Description copied from interface:SqlRexContextIf the operator call occurs in an aggregate query, returns whether there are empty groups in the GROUP BY clause. For example,SELECT count(*) FROM emp GROUP BY deptno, gender; returns false SELECT count(*) FROM emp; returns true SELECT count(*) FROM emp GROUP BY ROLLUP(deptno, gender); returns true
If the operator call occurs in window aggregate query, then returns false if the window is guaranteed to be non-empty, or true if the window might be empty.Returns false if the query is not an aggregate query.
- Specified by:
hasEmptyGroupin interfaceSqlRexContext- See Also:
-
getRexBuilder
Description copied from interface:SqlRexContextReturns theRexBuilderto use to createRexNodeobjects.- Specified by:
getRexBuilderin interfaceInitializerContext- Specified by:
getRexBuilderin interfaceSqlRexContext
-
validateExpression
Description copied from interface:InitializerContextValidate the expression with a base table row type. The expression may reference the fields of the row type defines.- Specified by:
validateExpressionin interfaceInitializerContext- Parameters:
rowType- the table row typeexpr- the expression- Returns:
- a validated
SqlNode, usually it transforms from aSqlUnresolvedFunctionto a resolved one
-
getSubQueryExpr
Description copied from interface:SqlRexContextReturns the expression used to access a given IN or EXISTSsub-query.- Specified by:
getSubQueryExprin interfaceSqlRexContext- Parameters:
call- IN or EXISTS expression- Returns:
- Expression used to access current row of sub-query
-
getTypeFactory
Description copied from interface:SqlRexContextReturns the type factory.- Specified by:
getTypeFactoryin interfaceSqlRexContext
-
getInitializerExpressionFactory
Description copied from interface:SqlRexContextReturns the factory which supplies default values for INSERT, UPDATE, and NEW.- Specified by:
getInitializerExpressionFactoryin interfaceSqlRexContext
-
getValidator
Description copied from interface:SqlRexContextReturns the validator.- Specified by:
getValidatorin interfaceSqlRexContext
-
convertLiteral
Description copied from interface:SqlRexContextConverts a literal.- Specified by:
convertLiteralin interfaceSqlRexContext
-
convertInterval
-
visit
Description copied from interface:SqlVisitorVisits a literal.- Specified by:
visitin interfaceSqlVisitor<RexNode>- Parameters:
literal- Literal- See Also:
-
visit
Description copied from interface:SqlVisitorVisits a call to aSqlOperator.- Specified by:
visitin interfaceSqlVisitor<RexNode>- Parameters:
call- Call- See Also:
-
visit
Description copied from interface:SqlVisitorVisits a list ofSqlNodeobjects.- Specified by:
visitin interfaceSqlVisitor<RexNode>- Parameters:
nodeList- list of nodes- See Also:
-
visit
Description copied from interface:SqlVisitorVisits an identifier.- Specified by:
visitin interfaceSqlVisitor<RexNode>- Parameters:
id- identifier- See Also:
-
visit
Description copied from interface:SqlVisitorVisits a datatype specification.- Specified by:
visitin interfaceSqlVisitor<RexNode>- Parameters:
type- datatype specification- See Also:
-
visit
Description copied from interface:SqlVisitorVisits a dynamic parameter.- Specified by:
visitin interfaceSqlVisitor<RexNode>- Parameters:
param- Dynamic parameter- See Also:
-
visit
Description copied from interface:SqlVisitorVisits an interval qualifier.- Specified by:
visitin interfaceSqlVisitor<RexNode>- Parameters:
intervalQualifier- Interval qualifier- See Also:
-
getColumnMonotonicities
-
lookupMeasure
-