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
Modifier and TypeFieldDescription@Nullable RelNode
final SqlValidatorScope
Collection ofRelNode
objects which correspond to a SELECT statement. -
Constructor Summary
ModifierConstructorDescriptionprotected
Blackboard
(@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.void
flatten
(List<RelNode> rels, int systemFieldCount, int[] start, BiConsumer<RelNode, Integer> relOffsetList) int
If the operator call occurs in an aggregate query, returns the number of columns in the GROUP BY clause.Returns the factory which supplies default values for INSERT, UPDATE, and NEW.Returns theRexBuilder
to use to createRexNode
objects.getSubQueryExpr
(SqlCall call) Returns the expression used to access a given IN or EXISTSsub-query
.Returns the type factory.Returns the validator.@Nullable SqlNode
lookupMeasure
(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 theregistered
with given root node and return the new root node.root()
scope()
Deprecated.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
Sets 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 ofSqlNode
objects.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
Collection ofRelNode
objects 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 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
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:
convertExpression
in interfaceInitializerContext
- Specified by:
convertExpression
in 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. -
getGroupCount
public int getGroupCount()Description copied from interface:SqlRexContext
If the operator call occurs in an aggregate query, returns the number of columns in the GROUP BY clause. For example, for "SELECT count(*) FROM emp GROUP BY deptno, gender", returns 2. If the operator call occurs in window aggregate query, then returns 1 if the window is guaranteed to be non-empty, or 0 if the window might be empty.Returns 0 if the query is implicitly "GROUP BY ()" because of an aggregate expression. For example, "SELECT sum(sal) FROM emp".
Returns -1 if the query is not an aggregate query.
- Specified by:
getGroupCount
in interfaceSqlRexContext
- Returns:
- 0 if the query is implicitly GROUP BY (), -1 if the query is not and aggregate query
- See Also:
-
getRexBuilder
Description copied from interface:SqlRexContext
Returns theRexBuilder
to use to createRexNode
objects.- Specified by:
getRexBuilder
in interfaceInitializerContext
- Specified by:
getRexBuilder
in interfaceSqlRexContext
-
validateExpression
Description copied from interface:InitializerContext
Validate the expression with a base table row type. The expression may reference the fields of the row type defines.- Specified by:
validateExpression
in interfaceInitializerContext
- Parameters:
rowType
- the table row typeexpr
- the expression- Returns:
- a validated
SqlNode
, usually it transforms from aSqlUnresolvedFunction
to a resolved one
-
getSubQueryExpr
Description copied from interface:SqlRexContext
Returns the expression used to access a given IN or EXISTSsub-query
.- Specified by:
getSubQueryExpr
in interfaceSqlRexContext
- Parameters:
call
- IN or EXISTS expression- Returns:
- Expression used to access current row of sub-query
-
getTypeFactory
Description copied from interface:SqlRexContext
Returns the type factory.- Specified by:
getTypeFactory
in interfaceSqlRexContext
-
getInitializerExpressionFactory
Description copied from interface:SqlRexContext
Returns the factory which supplies default values for INSERT, UPDATE, and NEW.- Specified by:
getInitializerExpressionFactory
in interfaceSqlRexContext
-
getValidator
Description copied from interface:SqlRexContext
Returns the validator.- Specified by:
getValidator
in interfaceSqlRexContext
-
convertLiteral
Description copied from interface:SqlRexContext
Converts a literal.- Specified by:
convertLiteral
in interfaceSqlRexContext
-
convertInterval
-
visit
Description copied from interface:SqlVisitor
Visits a literal.- Specified by:
visit
in interfaceSqlVisitor<RexNode>
- Parameters:
literal
- Literal- See Also:
-
visit
Description copied from interface:SqlVisitor
Visits a call to aSqlOperator
.- Specified by:
visit
in interfaceSqlVisitor<RexNode>
- Parameters:
call
- Call- See Also:
-
visit
Description copied from interface:SqlVisitor
Visits a list ofSqlNode
objects.- Specified by:
visit
in interfaceSqlVisitor<RexNode>
- Parameters:
nodeList
- list of nodes- See Also:
-
visit
Description copied from interface:SqlVisitor
Visits an identifier.- Specified by:
visit
in interfaceSqlVisitor<RexNode>
- Parameters:
id
- identifier- See Also:
-
visit
Description copied from interface:SqlVisitor
Visits a datatype specification.- Specified by:
visit
in interfaceSqlVisitor<RexNode>
- Parameters:
type
- datatype specification- See Also:
-
visit
Description copied from interface:SqlVisitor
Visits a dynamic parameter.- Specified by:
visit
in interfaceSqlVisitor<RexNode>
- Parameters:
param
- Dynamic parameter- See Also:
-
visit
Description copied from interface:SqlVisitor
Visits an interval qualifier.- Specified by:
visit
in interfaceSqlVisitor<RexNode>
- Parameters:
intervalQualifier
- Interval qualifier- See Also:
-
getColumnMonotonicities
-
lookupMeasure
-