|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.sql2rel.SqlToRelConverter
public class SqlToRelConverter
Converts a SQL parse tree (consisting of SqlNode
objects) into a relational algebra expression (consisting of RelNode
objects).
The public entry points are: convertQuery(org.eigenbase.sql.SqlNode, boolean, boolean)
, convertExpression(SqlNode)
.
Nested Class Summary | |
---|---|
protected class |
SqlToRelConverter.AggConverter
Converts expressions to aggregates. |
protected class |
SqlToRelConverter.Blackboard
Workspace for translating an individual SELECT statement (or sub-SELECT). |
private static class |
SqlToRelConverter.DeferredLookup
|
private class |
SqlToRelConverter.HistogramShuttle
Shuttle which walks over a tree of RexNode s and applies 'over' to
all agg functions. |
private static class |
SqlToRelConverter.LookupContext
Context to find a relational expression to a field offset. |
private class |
SqlToRelConverter.NoOpSubqueryConverter
A default implementation of SubqueryConverter that does no conversion. |
(package private) class |
SqlToRelConverter.NullDefaultValueFactory
An implementation of DefaultValueFactory which always supplies NULL. |
static class |
SqlToRelConverter.SchemaCatalogReader
A SchemaCatalogReader looks up catalog information from a
schema object . |
Constructor Summary | |
---|---|
SqlToRelConverter(SqlValidator validator,
RelOptSchema schema,
Environment env,
RelOptPlanner planner,
RelOptConnection connection,
RexBuilder rexBuilder)
Creates a converter. |
Method Summary | |
---|---|
void |
addConvertedNonCorrSubqs(Map<SqlNode,RexNode> alreadyConvertedNonCorrSubqs)
Adds to the current map of non-correlated converted subqueries the elements from another map that contains non-correlated subqueries that have been converted by another SqlToRelConverter. |
protected RexNode |
adjustInputRef(SqlToRelConverter.Blackboard bb,
RexInputRef inputRef)
Adjust the type of a reference to an input field to account for nulls introduced by outer joins; and adjust the offset to match the physical implementation. |
protected void |
afterTableFunction(SqlToRelConverter.Blackboard bb,
SqlCall call,
TableFunctionRel callRel)
|
private RexNode |
castNullLiteralIfNeeded(RexNode node,
RelDataType type)
|
protected boolean |
checkConvertedRowType(SqlNode query,
RelDataType convertedRowType)
|
private void |
checkConvertedType(SqlNode query,
RelNode result)
|
protected void |
collectInsertTargets(SqlInsert call,
RexNode sourceRef,
List<String> targetColumnNames,
List<RexNode> columnExprs)
Given an INSERT statement, collects the list of names to be populated and the expressions to put in them. |
private static boolean |
containsInOperator(SqlNode node)
Returns whether a given node contains a SqlInOperator . |
protected void |
convertAgg(SqlToRelConverter.Blackboard bb,
SqlSelect select,
List<SqlNode> orderExprList)
Converts the SELECT, GROUP BY and HAVING clauses of an aggregate query. |
protected void |
convertCollectionTable(SqlToRelConverter.Blackboard bb,
SqlCall call)
|
protected RelNode |
convertColumnList(SqlInsert call,
RelNode sourceRel)
Creates a source for an INSERT statement. |
private RelNode |
convertCursor(SqlToRelConverter.Blackboard bb,
SqlCall cursorCall)
|
private RelNode |
convertDelete(SqlDelete call)
|
RexDynamicParam |
convertDynamicParam(SqlDynamicParam dynamicParam)
|
private RelNode |
convertExists(SqlNode seek,
boolean isIn,
boolean isExists,
boolean needsOuterJoin)
Converts an EXISTS or IN predicate into a join. |
RexNode |
convertExpression(SqlNode node)
Converts an expression from SqlNode to RexNode format. |
RexNode |
convertExpression(SqlNode node,
Map<String,RexNode> nameToNodeMap)
Converts an expression from SqlNode to RexNode format,
mapping identifier references to predefined expressions. |
protected RexNode |
convertExtendedExpression(SqlNode node,
SqlToRelConverter.Blackboard bb)
Converts a non-standard expression. |
RexNode |
convertField(RelDataType inputRowType,
RelDataTypeField field)
|
protected void |
convertFrom(SqlToRelConverter.Blackboard bb,
SqlNode from)
Converts a FROM clause into a relational expression. |
private RexNode |
convertIdentifier(SqlToRelConverter.Blackboard bb,
SqlIdentifier identifier)
Converts an identifier into an expression in a given scope. |
protected RelNode |
convertInsert(SqlInsert call)
|
private RexNode |
convertInToOr(SqlToRelConverter.Blackboard bb,
RexNode[] leftKeys,
SqlNodeList valuesList,
boolean isNotIn)
Converts "x IN (1, 2, ...)" to "x=1 OR x=2 OR ...". |
private RexNode |
convertJoinCondition(SqlToRelConverter.Blackboard bb,
SqlNode condition,
SqlJoinOperator.ConditionType conditionType,
RelNode leftRel,
RelNode rightRel)
|
private static JoinRelType |
convertJoinType(SqlJoinOperator.JoinType joinType)
|
private RexLiteral |
convertLiteralInValuesList(SqlNode sqlNode,
SqlToRelConverter.Blackboard bb,
RelDataType rowType,
int iField)
|
private RelNode |
convertMerge(SqlMerge call)
|
private RelNode |
convertMultisets(SqlNode[] operands,
SqlToRelConverter.Blackboard bb)
|
private boolean |
convertNonCorrelatedSubq(SqlCall call,
SqlToRelConverter.Blackboard bb,
RelNode converted,
boolean isExists)
Determines if a subquery is non-correlated and if so, converts it to a constant. |
private void |
convertOrder(SqlSelect select,
SqlToRelConverter.Blackboard bb,
List<RelFieldCollation> collationList,
List<SqlNode> orderExprList)
|
private RelFieldCollation |
convertOrderItem(SqlSelect select,
SqlNode orderItem,
List<SqlNode> extraExprs,
RelFieldCollation.Direction direction)
|
private RexNode |
convertOver(SqlToRelConverter.Blackboard bb,
SqlNode node)
|
RelNode |
convertQuery(SqlNode query,
boolean needsValidation,
boolean top)
Converts an unvalidated query's parse tree into a relational expression. |
private RelNode |
convertQueryOrInList(SqlToRelConverter.Blackboard bb,
SqlNode seek)
|
protected RelNode |
convertQueryRecursive(SqlNode query,
boolean top)
Recursively converts a query to a relational expression. |
private RelNode |
convertRowConstructor(SqlToRelConverter.Blackboard bb,
SqlCall rowConstructor)
Converts a row constructor into a relational expression. |
private RelNode |
convertRowValues(SqlToRelConverter.Blackboard bb,
SqlNode rowList,
Collection<SqlNode> rows,
boolean allowLiteralsOnly)
|
RelNode |
convertSelect(SqlSelect select)
Converts a SELECT statement's parse tree into a relational expression. |
protected void |
convertSelectImpl(SqlToRelConverter.Blackboard bb,
SqlSelect select)
Implementation of convertSelect(SqlSelect) ; derived class may
override. |
private void |
convertSelectList(SqlToRelConverter.Blackboard bb,
SqlSelect select,
List<SqlNode> orderList)
|
protected RelNode |
convertSetOp(SqlCall call)
Converts a set operation (UNION, INTERSECT, MINUS) into relational expressions. |
RelNode |
convertToSingleValueSubq(SqlSelect select,
RelNode plan)
Converts the RelNode tree for a select statement to a select that produces a single value. |
private RelNode |
convertUpdate(SqlUpdate call)
|
private RexNode |
convertUsing(RelNode leftRel,
RelNode rightRel,
List<String> nameList)
Returns an expression for matching columns of a USING clause or inferred from NATURAL JOIN. |
private void |
convertValues(SqlToRelConverter.Blackboard bb,
SqlCall values)
Converts a values clause (as in "INSERT INTO T(x,y) VALUES (1,2)") into a relational expression. |
private void |
convertWhere(SqlToRelConverter.Blackboard bb,
SqlNode where)
Converts a WHERE clause. |
protected void |
createAggImpl(SqlToRelConverter.Blackboard bb,
SqlToRelConverter.AggConverter aggConverter,
SqlNodeList selectList,
SqlNodeList groupList,
SqlNode having,
List<SqlNode> orderExprList)
|
protected RelNode |
createAggregate(SqlToRelConverter.Blackboard bb,
int groupCount,
List<AggregateCall> aggCalls)
Creates an AggregateRel. |
protected SqlToRelConverter.Blackboard |
createBlackboard(SqlValidatorScope scope,
Map<String,RexNode> nameToNodeMap)
Factory method for creating translation workspace. |
private String |
createCorrel()
|
protected RelNode |
createJoin(RelNode left,
RelNode right,
RexNode condition,
JoinRelType joinType,
Set<String> variablesStopped)
Factory method that creates a join. |
protected RelNode |
createJoin(SqlToRelConverter.Blackboard bb,
RelNode leftRel,
RelNode rightRel,
RexNode joinCond,
JoinRelType joinType)
|
private RexNode |
createJoinConditionForIn(SqlToRelConverter.Blackboard bb,
RexNode[] leftKeys,
RelNode rightRel)
Creates the condition for a join implementing an IN clause. |
RelNode |
decorrelate(SqlNode query,
RelNode rootRel)
|
protected RelNode |
decorrelateQuery(RelNode rootRel)
|
private String |
deriveAlias(SqlNode node,
Collection<String> aliases,
int ordinal)
|
private void |
distinctify(SqlToRelConverter.Blackboard bb,
boolean checkForDupExprs)
Having translated 'SELECT ... |
protected boolean |
enableDecorrelation()
|
void |
enableTableAccessConversion(boolean enabled)
Controls whether table access references are converted to physical rels immediately. |
void |
enableValuesRelCreation(boolean enabled)
Controls whether instances of ValuesRel are generated. |
protected void |
extraSelectItems(SqlToRelConverter.Blackboard bb,
SqlSelect select,
List<RexNode> exprList,
List<String> nameList,
Collection<String> aliasList,
List<SqlMonotonicity> columnMonotonicityList)
Adds extra select items. |
private int |
findExpr(RexNode seek,
RexNode[] exprs,
int count)
|
private void |
findSubqueries(SqlToRelConverter.Blackboard bb,
SqlNode node,
boolean registerOnlyScalarSubqueries)
Builds a list of all IN or EXISTS operators
inside SQL parse tree. |
RelNode |
flattenTypes(RelNode rootRel,
boolean restructure)
|
private void |
gatherOrderExprs(SqlToRelConverter.Blackboard bb,
SqlSelect select,
SqlNodeList orderList,
List<SqlNode> extraOrderExprs,
List<RelFieldCollation> collationList)
Creates a list of collations required to implement the ORDER BY clause, if there is one. |
RelOptCluster |
getCluster()
|
private Set<RelColumnMapping> |
getColumnMappings(SqlOperator op)
|
private int |
getCorrelOrdinal(String correlName)
|
int |
getDynamicParamCount()
Returns the number of dynamic parameters encountered during translation; this must only be called after convertQuery(org.eigenbase.sql.SqlNode, boolean, boolean) . |
int |
getDynamicParamCountInExplain(boolean increment)
Returns the current count of the number of dynamic parameters in an EXPLAIN PLAN statement. |
RelDataType |
getDynamicParamType(int index)
Returns the type inferred for a dynamic parameter. |
protected int |
getInSubqueryThreshold()
Gets the list size threshold under which convertInToOr(org.eigenbase.sql2rel.SqlToRelConverter.Blackboard, org.eigenbase.rex.RexNode[], org.eigenbase.sql.SqlNodeList, boolean) is used. |
Map<SqlNode,RexNode> |
getMapConvertedNonCorrSubqs()
|
RexBuilder |
getRexBuilder()
Returns the row-expression builder. |
protected List<RelDataTypeField> |
getSystemFields()
Returns a list of fields to be prefixed to each relational expression. |
protected RelOptTable |
getTargetTable(SqlNode call)
|
boolean |
hasCorrelation()
|
private boolean |
isRowConstructor(SqlNode node)
|
private boolean |
isSubqNonCorrelated(RelNode subq,
SqlToRelConverter.Blackboard bb)
Determines whether a subquery is non-correlated. |
private static SqlNode |
pushdownNotForIn(SqlNode sqlNode)
Pushdown allthe NOT logical operators into any IN/NOT IN operators. |
private void |
replaceSubqueries(SqlToRelConverter.Blackboard bb,
SqlNode expr)
|
void |
setDefaultValueFactory(DefaultValueFactory factory)
Set a new DefaultValueFactory. |
void |
setIsExplain(int nDynamicParams)
Indicates that the current statement is part of an EXPLAIN PLAN statement |
void |
setSubqueryConverter(SubqueryConverter converter)
Sets a new SubqueryConverter. |
private void |
substituteSubquery(SqlToRelConverter.Blackboard bb,
SqlNode node)
|
protected RelDataType |
uniquifyFields(RelDataType rowType)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Logger sqlToRelTracer
protected final SqlValidator validator
protected final RexBuilder rexBuilder
private final RelOptConnection connection
protected final RelOptSchema schema
protected final RelOptCluster cluster
private final Map<SqlValidatorScope,SqlToRelConverter.LookupContext> mapScopeToLux
private DefaultValueFactory defaultValueFactory
private SubqueryConverter subqueryConverter
protected final List<RelNode> leaves
private final List<SqlDynamicParam> dynamicParamSqlNodes
private final SqlOperatorTable opTab
private boolean shouldConvertTableAccess
protected final RelDataTypeFactory typeFactory
private final SqlNodeToRexConverter exprConverter
private boolean decorrelationEnabled
private boolean shouldCreateValuesRel
private boolean isExplain
private int nDynamicParamsInExplain
private final Map<String,SqlToRelConverter.DeferredLookup> mapCorrelToDeferred
private int nextCorrel
private final String correlPrefix
private final Map<String,RelNode> mapCorrelToRefRel
private final SortedMap<CorrelatorRel.Correlation,CorrelatorRel> mapCorVarToCorRel
private final Map<RelNode,SortedSet<CorrelatorRel.Correlation>> mapRefRelToCorVar
private final Map<RexFieldAccess,CorrelatorRel.Correlation> mapFieldAccessToCorVar
private final Stack<String> datasetStack
TABLE(SAMPLE(<datasetName>, <query>))
construct.
private final Map<SqlNode,RexNode> mapConvertedNonCorrSubqs
Constructor Detail |
---|
public SqlToRelConverter(SqlValidator validator, RelOptSchema schema, Environment env, RelOptPlanner planner, RelOptConnection connection, RexBuilder rexBuilder)
validator
- Validatorschema
- Schemaenv
- Environmentconnection
- ConnectionrexBuilder
- Rex builderMethod Detail |
---|
public RelOptCluster getCluster()
public RexBuilder getRexBuilder()
public int getDynamicParamCount()
convertQuery(org.eigenbase.sql.SqlNode, boolean, boolean)
.
public RelDataType getDynamicParamType(int index)
index
- 0-based index of dynamic parameter
public int getDynamicParamCountInExplain(boolean increment)
increment
- if true, increment the count
public Map<SqlNode,RexNode> getMapConvertedNonCorrSubqs()
public void addConvertedNonCorrSubqs(Map<SqlNode,RexNode> alreadyConvertedNonCorrSubqs)
alreadyConvertedNonCorrSubqs
- the other mappublic void setDefaultValueFactory(DefaultValueFactory factory)
factory
- new DefaultValueFactorypublic void setSubqueryConverter(SubqueryConverter converter)
converter
- new SubqueryConverterpublic void setIsExplain(int nDynamicParams)
nDynamicParams
- number of dynamic parameters in the statementpublic void enableTableAccessConversion(boolean enabled)
CallingConvention.NONE
. However, if we are doing further conversion
passes (e.g. RelStructuredTypeFlattener
), then we may need to
defer conversion. To have any effect, this must be called before any
convert method.
enabled
- true for immediate conversion (the default); false to
generate logical TableAccessRel instancespublic void enableValuesRelCreation(boolean enabled)
ValuesRel
are generated. These may
not be supported by all physical implementations. To have any effect,
this must be called before any convert method.
enabled
- true to allow ValuesRel to be generated (the default);
false to force substitution of ProjectRel+OneRowRel insteadprivate void checkConvertedType(SqlNode query, RelNode result)
public RelNode flattenTypes(RelNode rootRel, boolean restructure)
public RelNode decorrelate(SqlNode query, RelNode rootRel)
public RelNode convertQuery(SqlNode query, boolean needsValidation, boolean top)
query
- Query to convertneedsValidation
- Whether to validate the query before converting;
false
if the query has already been validated.top
- Whether the query is top-level, say if its result will become
a JDBC result set; false
if the query will be part of a
view.protected boolean checkConvertedRowType(SqlNode query, RelDataType convertedRowType)
protected RelDataType uniquifyFields(RelDataType rowType)
public RelNode convertSelect(SqlSelect select)
protected SqlToRelConverter.Blackboard createBlackboard(SqlValidatorScope scope, Map<String,RexNode> nameToNodeMap)
protected void convertSelectImpl(SqlToRelConverter.Blackboard bb, SqlSelect select)
convertSelect(SqlSelect)
; derived class may
override.
private void distinctify(SqlToRelConverter.Blackboard bb, boolean checkForDupExprs)
If the SELECT clause contains duplicate expressions, adds ProjectRel
s so that we are grouping on the minimal set of keys. The
performance gain isn't huge, but it is difficult to detect these
duplicate expressions later.
bb
- BlackboardcheckForDupExprs
- Check for duplicate expressionsprivate int findExpr(RexNode seek, RexNode[] exprs, int count)
private void convertOrder(SqlSelect select, SqlToRelConverter.Blackboard bb, List<RelFieldCollation> collationList, List<SqlNode> orderExprList)
private static boolean containsInOperator(SqlNode node)
SqlInOperator
.
node
- a RexNode treeprivate static SqlNode pushdownNotForIn(SqlNode sqlNode)
sqlNode
- the root node from which to look for NOT operators
private void convertWhere(SqlToRelConverter.Blackboard bb, SqlNode where)
bb
- Blackboardwhere
- WHERE clause, may be nullprivate void replaceSubqueries(SqlToRelConverter.Blackboard bb, SqlNode expr)
private void substituteSubquery(SqlToRelConverter.Blackboard bb, SqlNode node)
private boolean convertNonCorrelatedSubq(SqlCall call, SqlToRelConverter.Blackboard bb, RelNode converted, boolean isExists)
call
- the call that references the subquerybb
- blackboard used to convert the subqueryconverted
- RelNode tree corresponding to the subqueryisExists
- true if the subquery is part of an EXISTS expression
public RelNode convertToSingleValueSubq(SqlSelect select, RelNode plan)
select
- the statementplan
- the original RelNode tree corresponding to the statement
private RexNode convertInToOr(SqlToRelConverter.Blackboard bb, RexNode[] leftKeys, SqlNodeList valuesList, boolean isNotIn)
leftKeys
- LHSvaluesList
- RHSisNotIn
- is this a NOT IN operator
protected int getInSubqueryThreshold()
convertInToOr(org.eigenbase.sql2rel.SqlToRelConverter.Blackboard, org.eigenbase.rex.RexNode[], org.eigenbase.sql.SqlNodeList, boolean)
is used.
Lists of this size or greater will instead be converted to use a join
against an inline table (ValuesRel
) rather than a predicate. A
threshold of 0 forces usage of an inline table in all cases; a threshold
of Integer.MAX_VALUE forces usage of OR in all cases
private RexNode createJoinConditionForIn(SqlToRelConverter.Blackboard bb, RexNode[] leftKeys, RelNode rightRel)
bb
- blackboard to use, bb.root points to the LHSleftKeys
- LHS of INrightRel
- Relational expression on RHS
private RelNode convertExists(SqlNode seek, boolean isIn, boolean isExists, boolean needsOuterJoin)
FIXME jvs 1-May-2006: null semantics for IN are currently broken
seek
- A query, for example 'select * from emp' or 'values (1,2,3)'
or '('Foo', 34)'.isIn
- Whether is an IN predicateisExists
- Whether is an EXISTS predicateneedsOuterJoin
- Whether an outer join is needed
private RelNode convertQueryOrInList(SqlToRelConverter.Blackboard bb, SqlNode seek)
private RelNode convertRowValues(SqlToRelConverter.Blackboard bb, SqlNode rowList, Collection<SqlNode> rows, boolean allowLiteralsOnly)
private RexLiteral convertLiteralInValuesList(SqlNode sqlNode, SqlToRelConverter.Blackboard bb, RelDataType rowType, int iField)
private boolean isRowConstructor(SqlNode node)
private void findSubqueries(SqlToRelConverter.Blackboard bb, SqlNode node, boolean registerOnlyScalarSubqueries)
IN
or EXISTS
operators
inside SQL parse tree. Does not traverse inside queries.
bb
- blackboardnode
- the SQL parse treeregisterOnlyScalarSubqueries
- if set to true and the parse tree
corresponds to a variation of a select node, only register it if it's a
scalar subquerypublic RexNode convertExpression(SqlNode node)
SqlNode
to RexNode
format.
node
- Expression to translate
public RexNode convertExpression(SqlNode node, Map<String,RexNode> nameToNodeMap)
SqlNode
to RexNode
format,
mapping identifier references to predefined expressions.
node
- Expression to translatenameToNodeMap
- map from String to RexNode
; when an SqlIdentifier
is encountered, it is used as a key and translated to the
corresponding value from this map
protected RexNode convertExtendedExpression(SqlNode node, SqlToRelConverter.Blackboard bb)
This method is an extension-point for derived classes can override. If this method returns a null result, the normal expression translation process will proceeed. The default implementation always returns null.
node
- Expressionbb
- Blackboard
private RexNode convertOver(SqlToRelConverter.Blackboard bb, SqlNode node)
protected void convertFrom(SqlToRelConverter.Blackboard bb, SqlNode from)
bb
- Scope within which to resolve identifiersfrom
- FROM clause of a query. Examples include:
protected void convertCollectionTable(SqlToRelConverter.Blackboard bb, SqlCall call)
protected void afterTableFunction(SqlToRelConverter.Blackboard bb, SqlCall call, TableFunctionRel callRel)
private Set<RelColumnMapping> getColumnMappings(SqlOperator op)
protected RelNode createJoin(SqlToRelConverter.Blackboard bb, RelNode leftRel, RelNode rightRel, RexNode joinCond, JoinRelType joinType)
private boolean isSubqNonCorrelated(RelNode subq, SqlToRelConverter.Blackboard bb)
subq
- the subquerybb
- blackboard used while converting the subquery, i.e., the
blackboard of the parent query of this subquery
protected List<RelDataTypeField> getSystemFields()
private RexNode convertJoinCondition(SqlToRelConverter.Blackboard bb, SqlNode condition, SqlJoinOperator.ConditionType conditionType, RelNode leftRel, RelNode rightRel)
private RexNode convertUsing(RelNode leftRel, RelNode rightRel, List<String> nameList)
leftRel
- Left input to the joinrightRel
- Right input to the joinnameList
- List of column names to join on
private static JoinRelType convertJoinType(SqlJoinOperator.JoinType joinType)
protected void convertAgg(SqlToRelConverter.Blackboard bb, SqlSelect select, List<SqlNode> orderExprList)
This method extracts SELECT, GROUP BY and HAVING clauses, and creates
an SqlToRelConverter.AggConverter
, then delegates to createAggImpl(org.eigenbase.sql2rel.SqlToRelConverter.Blackboard, org.eigenbase.sql2rel.SqlToRelConverter.AggConverter, org.eigenbase.sql.SqlNodeList, org.eigenbase.sql.SqlNodeList, org.eigenbase.sql.SqlNode, java.util.List
.
Derived class may override this method to change any of those clauses or
specify a different SqlToRelConverter.AggConverter
.
bb
- Scope within which to resolve identifiersselect
- QueryorderExprList
- Additional expressions needed to implement ORDER BYprotected final void createAggImpl(SqlToRelConverter.Blackboard bb, SqlToRelConverter.AggConverter aggConverter, SqlNodeList selectList, SqlNodeList groupList, SqlNode having, List<SqlNode> orderExprList)
protected RelNode createAggregate(SqlToRelConverter.Blackboard bb, int groupCount, List<AggregateCall> aggCalls)
In case the aggregate rel changes the order in which it projects
fields, the groupExprProjection
parameter is provided, and
the implementation of this method may modify it.
The sortedCount
parameter is the number of expressions
known to be monotonic. These expressions must be on the leading edge of
the grouping keys. The default implementation of this method ignores this
parameter.
bb
- BlackboardgroupCount
- Number of expressions to group onaggCalls
- Array of calls to aggregate functions
public RexDynamicParam convertDynamicParam(SqlDynamicParam dynamicParam)
private void gatherOrderExprs(SqlToRelConverter.Blackboard bb, SqlSelect select, SqlNodeList orderList, List<SqlNode> extraOrderExprs, List<RelFieldCollation> collationList)
extraOrderExprs
with any sort
expressions which are not in the select clause.
bb
- Scope within which to resolve identifiersselect
- Select clause, null if order by is applied to set operation
(UNION etc.)orderList
- Order by clause, may be nullextraOrderExprs
- Sort expressions which are not in the select
clause (output)collationList
- List of collations (output)private RelFieldCollation convertOrderItem(SqlSelect select, SqlNode orderItem, List<SqlNode> extraExprs, RelFieldCollation.Direction direction)
protected boolean enableDecorrelation()
public boolean hasCorrelation()
protected RelNode decorrelateQuery(RelNode rootRel)
protected RelNode convertQueryRecursive(SqlNode query, boolean top)
query
- Querytop
- Whether this query is the top-level query of the statement
protected RelNode convertSetOp(SqlCall call)
call
- Call to set operator
protected RelNode convertInsert(SqlInsert call)
protected RelOptTable getTargetTable(SqlNode call)
protected RelNode convertColumnList(SqlInsert call, RelNode sourceRel)
If the column list is not specified, source expressions match target columns in order.
If the column list is specified, Source expressions are mapped to target columns by name via targetColumnList, and may not cover the entire target table. So, we'll make up a full row, using a combination of default values and the source expressions provided.
call
- Insert expressionsourceRel
- Source relational expression
private RexNode castNullLiteralIfNeeded(RexNode node, RelDataType type)
protected void collectInsertTargets(SqlInsert call, RexNode sourceRef, List<String> targetColumnNames, List<RexNode> columnExprs)
call
- Insert statementsourceRef
- Expression representing a row from the source relational
expressiontargetColumnNames
- List of target column names, to be populatedcolumnExprs
- List of expressions, to be populatedprivate RelNode convertDelete(SqlDelete call)
private RelNode convertUpdate(SqlUpdate call)
private RelNode convertMerge(SqlMerge call)
private RexNode convertIdentifier(SqlToRelConverter.Blackboard bb, SqlIdentifier identifier)
protected RexNode adjustInputRef(SqlToRelConverter.Blackboard bb, RexInputRef inputRef)
bb
- BlackboardinputRef
- Input ref
private RelNode convertRowConstructor(SqlToRelConverter.Blackboard bb, SqlCall rowConstructor)
bb
- BlackboardrowConstructor
- Row constructor expression
private RelNode convertCursor(SqlToRelConverter.Blackboard bb, SqlCall cursorCall)
private RelNode convertMultisets(SqlNode[] operands, SqlToRelConverter.Blackboard bb)
protected RelNode createJoin(RelNode left, RelNode right, RexNode condition, JoinRelType joinType, Set<String> variablesStopped)
left
- Left inputright
- Right inputcondition
- Join conditionjoinType
- Join typevariablesStopped
- Set of names of variables which are set by the
LHS and used by the RHS and are not available to nodes above this JoinRel
in the tree
private void convertSelectList(SqlToRelConverter.Blackboard bb, SqlSelect select, List<SqlNode> orderList)
protected void extraSelectItems(SqlToRelConverter.Blackboard bb, SqlSelect select, List<RexNode> exprList, List<String> nameList, Collection<String> aliasList, List<SqlMonotonicity> columnMonotonicityList)
bb
- Blackboardselect
- Select statement being translatedexprList
- List of expressions in select clausenameList
- List of names, one per columnaliasList
- Collection of aliases that have been used alreadycolumnMonotonicityList
- List of monotonicity, one per columnprivate String deriveAlias(SqlNode node, Collection<String> aliases, int ordinal)
private void convertValues(SqlToRelConverter.Blackboard bb, SqlCall values)
public RexNode convertField(RelDataType inputRowType, RelDataTypeField field)
private String createCorrel()
private int getCorrelOrdinal(String correlName)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |