Package org.apache.calcite.sql2rel
Class SqlToRelConverter.Blackboard
java.lang.Object
org.apache.calcite.sql2rel.SqlToRelConverter.Blackboard
- All Implemented Interfaces:
org.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.rex.RexNode>,org.apache.calcite.sql2rel.InitializerContext,org.apache.calcite.sql2rel.SqlRexContext
- Enclosing class:
- SqlToRelConverter
protected class SqlToRelConverter.Blackboard
extends Object
implements org.apache.calcite.sql2rel.SqlRexContext, org.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.rex.RexNode>, org.apache.calcite.sql2rel.InitializerContext
Workspace for translating an individual SELECT statement (or sub-SELECT).
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBlackboard(@Nullable org.apache.calcite.sql.validate.SqlValidatorScope scope, @Nullable Map<String, org.apache.calcite.rex.RexNode> nameToNodeMap, boolean top) Creates a Blackboard. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.calcite.rex.RexNodeconvertExpression(org.apache.calcite.sql.SqlNode expr) org.apache.calcite.rex.RexNodeconvertInterval(org.apache.calcite.sql.SqlIntervalQualifier intervalQualifier) org.apache.calcite.rex.RexNodeconvertLiteral(org.apache.calcite.sql.SqlLiteral literal) org.apache.calcite.rex.RexFieldCollationconvertSortExpression(org.apache.calcite.sql.SqlNode expr, org.apache.calcite.rel.RelFieldCollation.Direction direction, org.apache.calcite.rel.RelFieldCollation.NullDirection nullDirection) Deprecated.voidflatten(List<org.apache.calcite.rel.RelNode> rels, int systemFieldCount, int[] start, List<org.apache.calcite.util.Pair<org.apache.calcite.rel.RelNode, Integer>> relOffsetList) List<org.apache.calcite.sql.validate.SqlMonotonicity>intorg.apache.calcite.sql2rel.InitializerExpressionFactoryorg.apache.calcite.rex.RexBuilderorg.apache.calcite.rex.RexRangeRefgetSubQueryExpr(org.apache.calcite.sql.SqlCall call) org.apache.calcite.rel.type.RelDataTypeFactoryorg.apache.calcite.sql.validate.SqlValidatororg.apache.calcite.rex.RexNoderegister(org.apache.calcite.rel.RelNode rel, org.apache.calcite.rel.core.JoinRelType joinType) org.apache.calcite.rex.RexNoderegister(org.apache.calcite.rel.RelNode rel, org.apache.calcite.rel.core.JoinRelType joinType, @Nullable List<org.apache.calcite.rex.RexNode> leftKeys) Registers a relational expression.org.apache.calcite.rel.RelNodereRegister(org.apache.calcite.rel.RelNode root) Re-register theregisteredwith given root node and return the new root node.org.apache.calcite.rel.RelNoderoot()org.apache.calcite.sql.validate.SqlValidatorScopescope()voidsetDataset(@Nullable String datasetName) Notifies this Blackboard that the root just set usingsetRoot(RelNode, boolean)was derived using dataset substitution.voidsetPatternVarRef(boolean isVarRef) voidsetRoot(org.apache.calcite.rel.RelNode root, boolean leaf) Sets a new root relational expression, as the translation process backs its way further up the tree.org.apache.calcite.sql.SqlNodevalidateExpression(org.apache.calcite.rel.type.RelDataType rowType, org.apache.calcite.sql.SqlNode expr) org.apache.calcite.rex.RexNodevisit(org.apache.calcite.sql.SqlCall call) org.apache.calcite.rex.RexNodevisit(org.apache.calcite.sql.SqlDataTypeSpec type) org.apache.calcite.rex.RexNodevisit(org.apache.calcite.sql.SqlDynamicParam param) org.apache.calcite.rex.RexNodevisit(org.apache.calcite.sql.SqlIdentifier id) org.apache.calcite.rex.RexNodevisit(org.apache.calcite.sql.SqlIntervalQualifier intervalQualifier) org.apache.calcite.rex.RexNodevisit(org.apache.calcite.sql.SqlLiteral literal) org.apache.calcite.rex.RexNodevisit(org.apache.calcite.sql.SqlNodeList nodeList) 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
visitNode
-
Field Details
-
scope
public final @Nullable org.apache.calcite.sql.validate.SqlValidatorScope scopeCollection ofRelNodeobjects which correspond to a SELECT statement. -
root
public @Nullable org.apache.calcite.rel.RelNode root
-
-
Constructor Details
-
Blackboard
protected Blackboard(@Nullable org.apache.calcite.sql.validate.SqlValidatorScope scope, @Nullable Map<String, org.apache.calcite.rex.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
public org.apache.calcite.rel.RelNode root() -
scope
public org.apache.calcite.sql.validate.SqlValidatorScope scope() -
setPatternVarRef
public void setPatternVarRef(boolean isVarRef) -
register
public org.apache.calcite.rex.RexNode register(org.apache.calcite.rel.RelNode rel, org.apache.calcite.rel.core.JoinRelType joinType) -
register
public org.apache.calcite.rex.RexNode register(org.apache.calcite.rel.RelNode rel, org.apache.calcite.rel.core.JoinRelType joinType, @Nullable List<org.apache.calcite.rex.RexNode> leftKeys) 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
public org.apache.calcite.rel.RelNode reRegister(org.apache.calcite.rel.RelNode root) 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
public void setRoot(org.apache.calcite.rel.RelNode root, boolean leaf) 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
-
convertExpression
public org.apache.calcite.rex.RexNode convertExpression(org.apache.calcite.sql.SqlNode expr) - Specified by:
convertExpressionin interfaceorg.apache.calcite.sql2rel.InitializerContext- Specified by:
convertExpressionin interfaceorg.apache.calcite.sql2rel.SqlRexContext
-
convertSortExpression
@Deprecated public org.apache.calcite.rex.RexFieldCollation convertSortExpression(org.apache.calcite.sql.SqlNode expr, org.apache.calcite.rel.RelFieldCollation.Direction direction, org.apache.calcite.rel.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. -
getGroupCount
public int getGroupCount()- Specified by:
getGroupCountin interfaceorg.apache.calcite.sql2rel.SqlRexContext
-
getRexBuilder
public org.apache.calcite.rex.RexBuilder getRexBuilder()- Specified by:
getRexBuilderin interfaceorg.apache.calcite.sql2rel.InitializerContext- Specified by:
getRexBuilderin interfaceorg.apache.calcite.sql2rel.SqlRexContext
-
validateExpression
public org.apache.calcite.sql.SqlNode validateExpression(org.apache.calcite.rel.type.RelDataType rowType, org.apache.calcite.sql.SqlNode expr) - Specified by:
validateExpressionin interfaceorg.apache.calcite.sql2rel.InitializerContext
-
getSubQueryExpr
public org.apache.calcite.rex.RexRangeRef getSubQueryExpr(org.apache.calcite.sql.SqlCall call) - Specified by:
getSubQueryExprin interfaceorg.apache.calcite.sql2rel.SqlRexContext
-
getTypeFactory
public org.apache.calcite.rel.type.RelDataTypeFactory getTypeFactory()- Specified by:
getTypeFactoryin interfaceorg.apache.calcite.sql2rel.SqlRexContext
-
getInitializerExpressionFactory
public org.apache.calcite.sql2rel.InitializerExpressionFactory getInitializerExpressionFactory()- Specified by:
getInitializerExpressionFactoryin interfaceorg.apache.calcite.sql2rel.SqlRexContext
-
getValidator
public org.apache.calcite.sql.validate.SqlValidator getValidator()- Specified by:
getValidatorin interfaceorg.apache.calcite.sql2rel.SqlRexContext
-
convertLiteral
public org.apache.calcite.rex.RexNode convertLiteral(org.apache.calcite.sql.SqlLiteral literal) - Specified by:
convertLiteralin interfaceorg.apache.calcite.sql2rel.SqlRexContext
-
convertInterval
public org.apache.calcite.rex.RexNode convertInterval(org.apache.calcite.sql.SqlIntervalQualifier intervalQualifier) -
visit
public org.apache.calcite.rex.RexNode visit(org.apache.calcite.sql.SqlLiteral literal) - Specified by:
visitin interfaceorg.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.rex.RexNode>
-
visit
public org.apache.calcite.rex.RexNode visit(org.apache.calcite.sql.SqlCall call) - Specified by:
visitin interfaceorg.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.rex.RexNode>
-
visit
public org.apache.calcite.rex.RexNode visit(org.apache.calcite.sql.SqlNodeList nodeList) - Specified by:
visitin interfaceorg.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.rex.RexNode>
-
visit
public org.apache.calcite.rex.RexNode visit(org.apache.calcite.sql.SqlIdentifier id) - Specified by:
visitin interfaceorg.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.rex.RexNode>
-
visit
public org.apache.calcite.rex.RexNode visit(org.apache.calcite.sql.SqlDataTypeSpec type) - Specified by:
visitin interfaceorg.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.rex.RexNode>
-
visit
public org.apache.calcite.rex.RexNode visit(org.apache.calcite.sql.SqlDynamicParam param) - Specified by:
visitin interfaceorg.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.rex.RexNode>
-
visit
public org.apache.calcite.rex.RexNode visit(org.apache.calcite.sql.SqlIntervalQualifier intervalQualifier) - Specified by:
visitin interfaceorg.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.rex.RexNode>
-
getColumnMonotonicities
-