protected class SqlToRelConverter.Blackboard extends Object implements SqlRexContext, SqlVisitor<RexNode>, InitializerContext
| Modifier and Type | Field and Description |
|---|---|
@Nullable RelNode |
root |
@Nullable SqlValidatorScope |
scope
Collection of
RelNode objects which correspond to a SELECT
statement. |
| Modifier | Constructor and Description |
|---|---|
protected |
Blackboard(@Nullable SqlValidatorScope scope,
@Nullable Map<String,RexNode> nameToNodeMap,
boolean top)
Creates a Blackboard.
|
| Modifier and Type | Method and Description |
|---|---|
RexNode |
convertExpression(SqlNode expr)
|
RexNode |
convertInterval(SqlIntervalQualifier intervalQualifier) |
RexNode |
convertLiteral(SqlLiteral literal)
Converts a literal.
|
RexFieldCollation |
convertSortExpression(SqlNode expr,
RelFieldCollation.Direction direction,
RelFieldCollation.NullDirection nullDirection)
Converts an item in an ORDER BY clause inside a window (OVER) clause,
extracting DESC, NULLS LAST and NULLS FIRST flags first.
|
void |
flatten(List<RelNode> rels,
int systemFieldCount,
int[] start,
List<Pair<RelNode,Integer>> relOffsetList) |
List<SqlMonotonicity> |
getColumnMonotonicities() |
int |
getGroupCount()
If the operator call occurs in an aggregate query, returns the number of
columns in the GROUP BY clause.
|
InitializerExpressionFactory |
getInitializerExpressionFactory()
Returns the factory which supplies default values for INSERT, UPDATE, and
NEW.
|
RexBuilder |
getRexBuilder()
Returns the
RexBuilder to use to create RexNode objects. |
RexRangeRef |
getSubQueryExpr(SqlCall call)
Returns the expression used to access a given IN or EXISTS
sub-query. |
RelDataTypeFactory |
getTypeFactory()
Returns the type factory.
|
SqlValidator |
getValidator()
Returns the validator.
|
RexNode |
register(RelNode rel,
JoinRelType joinType) |
RexNode |
register(RelNode rel,
JoinRelType joinType,
@Nullable List<RexNode> leftKeys)
Registers a relational expression.
|
RelNode |
reRegister(RelNode root)
Re-register the
registered with given root node and
return the new root node. |
RelNode |
root() |
SqlValidatorScope |
scope() |
void |
setDataset(@Nullable String datasetName)
Notifies this Blackboard that the root just set using
setRoot(RelNode, boolean) was derived using dataset
substitution. |
void |
setPatternVarRef(boolean isVarRef) |
void |
setRoot(RelNode root,
boolean leaf)
Sets a new root relational expression, as the translation process
backs its way further up the tree.
|
SqlNode |
validateExpression(RelDataType rowType,
SqlNode expr)
Validate the expression with a base table row type.
|
RexNode |
visit(SqlCall call)
Visits a call to a
SqlOperator. |
RexNode |
visit(SqlDataTypeSpec type)
Visits a datatype specification.
|
RexNode |
visit(SqlDynamicParam param)
Visits a dynamic parameter.
|
RexNode |
visit(SqlIdentifier id)
Visits an identifier.
|
RexNode |
visit(SqlIntervalQualifier intervalQualifier)
Visits an interval qualifier.
|
RexNode |
visit(SqlLiteral literal)
Visits a literal.
|
RexNode |
visit(SqlNodeList nodeList)
Visits a list of
SqlNode objects. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitparseExpressionpublic final @Nullable SqlValidatorScope scope
RelNode objects which correspond to a SELECT
statement.public @Nullable RelNode root
protected Blackboard(@Nullable SqlValidatorScope scope, @Nullable Map<String,RexNode> nameToNodeMap, boolean top)
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 querypublic RelNode root()
public SqlValidatorScope scope()
public void setPatternVarRef(boolean isVarRef)
public RexNode register(RelNode rel, JoinRelType joinType)
public RexNode register(RelNode rel, JoinRelType joinType, @Nullable List<RexNode> leftKeys)
rel - Relational expressionjoinType - Join typeleftKeys - LHS of IN clause, or null for expressions
other than INpublic RelNode reRegister(RelNode root)
registered with given root node and
return the new root node.root - The given root, never leafpublic void setRoot(RelNode root, boolean leaf)
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.public void setDataset(@Nullable String datasetName)
setRoot(RelNode, boolean) was derived using dataset
substitution.
The default implementation is not interested in such notifications, and does nothing.
datasetName - Dataset namepublic void flatten(List<RelNode> rels, int systemFieldCount, int[] start, List<Pair<RelNode,Integer>> relOffsetList)
public RexNode convertExpression(SqlNode expr)
SqlRexContextconvertExpression in interface InitializerContextconvertExpression in interface SqlRexContextexpr - Expression to translatepublic RexFieldCollation convertSortExpression(SqlNode expr, RelFieldCollation.Direction direction, RelFieldCollation.NullDirection nullDirection)
public int getGroupCount()
SqlRexContextReturns 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.
getGroupCount in interface SqlRexContextSqlOperatorBinding.getGroupCount()public RexBuilder getRexBuilder()
SqlRexContextRexBuilder to use to create RexNode objects.getRexBuilder in interface InitializerContextgetRexBuilder in interface SqlRexContextpublic SqlNode validateExpression(RelDataType rowType, SqlNode expr)
InitializerContextvalidateExpression in interface InitializerContextrowType - the table row typeexpr - the expressionSqlNode, usually it transforms
from a SqlUnresolvedFunction to a resolved onepublic RexRangeRef getSubQueryExpr(SqlCall call)
SqlRexContextsub-query.getSubQueryExpr in interface SqlRexContextcall - IN or EXISTS expressionpublic RelDataTypeFactory getTypeFactory()
SqlRexContextgetTypeFactory in interface SqlRexContextpublic InitializerExpressionFactory getInitializerExpressionFactory()
SqlRexContextgetInitializerExpressionFactory in interface SqlRexContextpublic SqlValidator getValidator()
SqlRexContextgetValidator in interface SqlRexContextpublic RexNode convertLiteral(SqlLiteral literal)
SqlRexContextconvertLiteral in interface SqlRexContextpublic RexNode convertInterval(SqlIntervalQualifier intervalQualifier)
public RexNode visit(SqlLiteral literal)
SqlVisitorvisit in interface SqlVisitor<RexNode>literal - LiteralSqlLiteral.accept(SqlVisitor)public RexNode visit(SqlCall call)
SqlVisitorSqlOperator.visit in interface SqlVisitor<RexNode>call - CallSqlCall.accept(SqlVisitor)public RexNode visit(SqlNodeList nodeList)
SqlVisitorSqlNode objects.visit in interface SqlVisitor<RexNode>nodeList - list of nodesSqlNodeList.accept(SqlVisitor)public RexNode visit(SqlIdentifier id)
SqlVisitorvisit in interface SqlVisitor<RexNode>id - identifierSqlIdentifier.accept(SqlVisitor)public RexNode visit(SqlDataTypeSpec type)
SqlVisitorvisit in interface SqlVisitor<RexNode>type - datatype specificationSqlDataTypeSpec.accept(SqlVisitor)public RexNode visit(SqlDynamicParam param)
SqlVisitorvisit in interface SqlVisitor<RexNode>param - Dynamic parameterSqlDynamicParam.accept(SqlVisitor)public RexNode visit(SqlIntervalQualifier intervalQualifier)
SqlVisitorvisit in interface SqlVisitor<RexNode>intervalQualifier - Interval qualifierSqlIntervalQualifier.accept(SqlVisitor)public List<SqlMonotonicity> getColumnMonotonicities()
Copyright © 2012-2022 Apache Software Foundation. All Rights Reserved.