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
ConstructorsModifierConstructorDescriptionprotected
Blackboard
(@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.RexNode
convertExpression
(org.apache.calcite.sql.SqlNode expr) org.apache.calcite.rex.RexNode
convertInterval
(org.apache.calcite.sql.SqlIntervalQualifier intervalQualifier) org.apache.calcite.rex.RexNode
convertLiteral
(org.apache.calcite.sql.SqlLiteral literal) 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.void
flatten
(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>
int
org.apache.calcite.sql2rel.InitializerExpressionFactory
org.apache.calcite.rex.RexBuilder
org.apache.calcite.rex.RexRangeRef
getSubQueryExpr
(org.apache.calcite.sql.SqlCall call) org.apache.calcite.rel.type.RelDataTypeFactory
org.apache.calcite.sql.validate.SqlValidator
org.apache.calcite.rex.RexNode
register
(org.apache.calcite.rel.RelNode rel, org.apache.calcite.rel.core.JoinRelType joinType) 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.org.apache.calcite.rel.RelNode
reRegister
(org.apache.calcite.rel.RelNode root) Re-register theregistered
with given root node and return the new root node.org.apache.calcite.rel.RelNode
root()
org.apache.calcite.sql.validate.SqlValidatorScope
scope()
void
setDataset
(@Nullable String datasetName) Notifies this Blackboard that the root just set usingsetRoot(RelNode, boolean)
was derived using dataset substitution.void
setPatternVarRef
(boolean isVarRef) 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.org.apache.calcite.sql.SqlNode
validateExpression
(org.apache.calcite.rel.type.RelDataType rowType, org.apache.calcite.sql.SqlNode expr) org.apache.calcite.rex.RexNode
visit
(org.apache.calcite.sql.SqlCall call) org.apache.calcite.rex.RexNode
visit
(org.apache.calcite.sql.SqlDataTypeSpec type) org.apache.calcite.rex.RexNode
visit
(org.apache.calcite.sql.SqlDynamicParam param) org.apache.calcite.rex.RexNode
visit
(org.apache.calcite.sql.SqlIdentifier id) org.apache.calcite.rex.RexNode
visit
(org.apache.calcite.sql.SqlIntervalQualifier intervalQualifier) org.apache.calcite.rex.RexNode
visit
(org.apache.calcite.sql.SqlLiteral literal) org.apache.calcite.rex.RexNode
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.sql2rel.InitializerContext
parseExpression
Methods inherited from interface org.apache.calcite.sql.util.SqlVisitor
visitNode
-
Field Details
-
scope
public final @Nullable org.apache.calcite.sql.validate.SqlValidatorScope scopeCollection ofRelNode
objects 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 theregistered
with 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:
convertExpression
in interfaceorg.apache.calcite.sql2rel.InitializerContext
- Specified by:
convertExpression
in 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:
getGroupCount
in interfaceorg.apache.calcite.sql2rel.SqlRexContext
-
getRexBuilder
public org.apache.calcite.rex.RexBuilder getRexBuilder()- Specified by:
getRexBuilder
in interfaceorg.apache.calcite.sql2rel.InitializerContext
- Specified by:
getRexBuilder
in 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:
validateExpression
in interfaceorg.apache.calcite.sql2rel.InitializerContext
-
getSubQueryExpr
public org.apache.calcite.rex.RexRangeRef getSubQueryExpr(org.apache.calcite.sql.SqlCall call) - Specified by:
getSubQueryExpr
in interfaceorg.apache.calcite.sql2rel.SqlRexContext
-
getTypeFactory
public org.apache.calcite.rel.type.RelDataTypeFactory getTypeFactory()- Specified by:
getTypeFactory
in interfaceorg.apache.calcite.sql2rel.SqlRexContext
-
getInitializerExpressionFactory
public org.apache.calcite.sql2rel.InitializerExpressionFactory getInitializerExpressionFactory()- Specified by:
getInitializerExpressionFactory
in interfaceorg.apache.calcite.sql2rel.SqlRexContext
-
getValidator
public org.apache.calcite.sql.validate.SqlValidator getValidator()- Specified by:
getValidator
in interfaceorg.apache.calcite.sql2rel.SqlRexContext
-
convertLiteral
public org.apache.calcite.rex.RexNode convertLiteral(org.apache.calcite.sql.SqlLiteral literal) - Specified by:
convertLiteral
in 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:
visit
in 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:
visit
in 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:
visit
in 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:
visit
in 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:
visit
in 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:
visit
in 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:
visit
in interfaceorg.apache.calcite.sql.util.SqlVisitor<org.apache.calcite.rex.RexNode>
-
getColumnMonotonicities
-