protected class SqlToRelConverter.Blackboard extends Object implements SqlRexContext, SqlVisitor<RexNode>, InitializerContext
| Modifier and Type | Field and Description |
|---|---|
(package private) SqlToRelConverter.AggConverter |
agg
Workspace for building aggregates.
|
private List<SqlMonotonicity> |
columnMonotonicities |
(package private) List<RelNode> |
cursors |
private InitializerExpressionFactory |
initializerExpressionFactory |
private List<RelNode> |
inputs |
private boolean |
isPatternVarRef |
private Map<CorrelationId,RexFieldAccess> |
mapCorrelateToRex |
private Map<RelNode,Map<Integer,Integer>> |
mapRootRelToFieldProjection
Project the groupby expressions out of the root of this sub-select.
|
private Map<String,RexNode> |
nameToNodeMap |
RelNode |
root |
SqlValidatorScope |
scope
Collection of
RelNode objects which correspond to a SELECT
statement. |
private Set<SqlToRelConverter.SubQuery> |
subQueryList
List of
IN and EXISTS nodes inside this
SELECT statement (but not inside sub-queries). |
private List<RelDataTypeField> |
systemFieldList |
(package private) boolean |
top |
(package private) SqlWindow |
window
When converting window aggregate, we need to know if the window is
guaranteed to be non-empty.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Blackboard(SqlValidatorScope scope,
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.
|
RexNode |
convertSortExpression(SqlNode expr,
Set<SqlKind> flags)
Converts an item in an ORDER BY 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. |
(package private) RelDataTypeField |
getRootField(RexInputRef inputRef) |
(package private) SqlToRelConverter.SubQuery |
getSubQuery(SqlNode expr) |
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.
|
private boolean |
isConvertedSubq(RexNode rex)
Determines whether a RexNode corresponds to a sub-query that's been
converted to a constant.
|
(package private) RexNode |
lookup(int offset,
SqlToRelConverter.LookupContext lookupContext)
Creates an expression with which to reference the expression whose
offset in its from-list is
offset. |
(package private) Pair<RexNode,Map<String,Integer>> |
lookupExp(SqlQualified qualified)
Returns an expression with which to reference a from-list item.
|
RexNode |
register(RelNode rel,
JoinRelType joinType) |
RexNode |
register(RelNode rel,
JoinRelType joinType,
List<RexNode> leftKeys)
Registers a relational expression.
|
(package private) void |
registerSubQuery(SqlNode node,
RelOptUtil.Logic logic) |
(package private) com.google.common.collect.ImmutableList<RelNode> |
retrieveCursors() |
void |
setDataset(String datasetName)
Notifies this Blackboard that the root just set using
setRoot(RelNode, boolean) was derived using dataset
substitution. |
void |
setPatternVarRef(boolean isVarRef) |
(package private) void |
setRoot(List<RelNode> inputs) |
private void |
setRoot(List<RelNode> inputs,
RelNode root,
boolean hasSystemFields) |
void |
setRoot(RelNode root,
boolean leaf)
Sets a new root relational expression, as the translation process
backs its way further up the tree.
|
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. |
public final SqlValidatorScope scope
RelNode objects which correspond to a SELECT
statement.public RelNode root
private final Map<CorrelationId,RexFieldAccess> mapCorrelateToRex
private boolean isPatternVarRef
private final Set<SqlToRelConverter.SubQuery> subQueryList
IN and EXISTS nodes inside this
SELECT statement (but not inside sub-queries).SqlToRelConverter.AggConverter agg
SqlWindow window
private final Map<RelNode,Map<Integer,Integer>> mapRootRelToFieldProjection
private final List<SqlMonotonicity> columnMonotonicities
private final List<RelDataTypeField> systemFieldList
final boolean top
private final InitializerExpressionFactory initializerExpressionFactory
protected Blackboard(SqlValidatorScope scope, 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 void setPatternVarRef(boolean isVarRef)
public RexNode register(RelNode rel, JoinRelType joinType)
public RexNode register(RelNode rel, JoinRelType joinType, List<RexNode> leftKeys)
rel - Relational expressionjoinType - Join typeleftKeys - LHS of IN clause, or null for expressions
other than INpublic 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(String datasetName)
setRoot(RelNode, boolean) was derived using dataset
substitution.
The default implementation is not interested in such notifications, and does nothing.
datasetName - Dataset namePair<RexNode,Map<String,Integer>> lookupExp(SqlQualified qualified)
qualified - the alias of the from itemRexFieldAccess or RexRangeRef, or null if
not foundRexNode lookup(int offset, SqlToRelConverter.LookupContext lookupContext)
offset.RelDataTypeField getRootField(RexInputRef inputRef)
public void flatten(List<RelNode> rels, int systemFieldCount, int[] start, List<Pair<RelNode,Integer>> relOffsetList)
void registerSubQuery(SqlNode node, RelOptUtil.Logic logic)
SqlToRelConverter.SubQuery getSubQuery(SqlNode expr)
com.google.common.collect.ImmutableList<RelNode> retrieveCursors()
public RexNode convertExpression(SqlNode expr)
SqlRexContextconvertExpression in interface InitializerContextconvertExpression in interface SqlRexContextexpr - Expression to translatepublic RexNode convertSortExpression(SqlNode expr, Set<SqlKind> flags)
private boolean isConvertedSubq(RexNode rex)
rex - the expression to be examinedpublic 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 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–2018 The Apache Software Foundation. All rights reserved.