public class RelStructuredTypeFlattener extends Object implements ReflectiveVisitor
As an example, suppose we have a structured type ST(A1 smallint, A2
bigint), a table T(c1 ST, c2 double), and a query
select t.c2, t.c1.a2 from t. After SqlToRelConverter executes, the
unflattened tree looks like:
LogicalProject(C2=[$1], A2=[$0.A2]) LogicalTableScan(table=[T])
After flattening, the resulting tree looks like
LogicalProject(C2=[$3], A2=[$2]) FtrsIndexScanRel(table=[T], index=[clustered])
The index scan produces a flattened row type (boolean, smallint,
bigint, double) (the boolean is a null indicator for c1), and the
projection picks out the desired attributes (omitting $0 and
$1 altogether). After optimization, the projection might be
pushed down into the index scan, resulting in a final tree like
FtrsIndexScanRel(table=[T], index=[clustered], projection=[3, 2])
| Modifier and Type | Class and Description |
|---|---|
static interface |
RelStructuredTypeFlattener.SelfFlatteningRel
Mix-in interface for relational expressions that know how to
flatten themselves.
|
| Constructor and Description |
|---|
RelStructuredTypeFlattener(RelBuilder relBuilder,
RexBuilder rexBuilder,
RelOptTable.ToRelContext toRelContext,
boolean restructure) |
RelStructuredTypeFlattener(RexBuilder rexBuilder,
RelOptTable.ToRelContext toRelContext,
boolean restructure)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
protected org.apache.calcite.linq4j.Ord<RelDataType> |
getNewFieldForOldInput(int oldOrdinal)
Maps the ordinal of a field pre-flattening to the ordinal of the
corresponding field post-flattening, and also returns its type.
|
protected int |
getNewForOldInput(int oldOrdinal)
Maps the ordinal of a field pre-flattening to the ordinal of the
corresponding field post-flattening.
|
protected RelNode |
getNewForOldRel(RelNode oldRel) |
RelNode |
rewrite(RelNode root) |
void |
rewriteGeneric(RelNode rel) |
void |
rewriteRel(Collect rel) |
void |
rewriteRel(LogicalAggregate rel) |
void |
rewriteRel(LogicalCalc rel) |
void |
rewriteRel(LogicalChi rel) |
void |
rewriteRel(LogicalCorrelate rel) |
void |
rewriteRel(LogicalDelta rel) |
void |
rewriteRel(LogicalFilter rel) |
void |
rewriteRel(LogicalIntersect rel) |
void |
rewriteRel(LogicalJoin rel) |
void |
rewriteRel(LogicalMatch rel) |
void |
rewriteRel(LogicalMinus rel) |
void |
rewriteRel(LogicalProject rel) |
void |
rewriteRel(LogicalSnapshot rel) |
void |
rewriteRel(LogicalTableFunctionScan rel) |
void |
rewriteRel(LogicalTableModify rel) |
void |
rewriteRel(LogicalUnion rel) |
void |
rewriteRel(LogicalValues rel) |
void |
rewriteRel(RelStructuredTypeFlattener.SelfFlatteningRel rel) |
void |
rewriteRel(Sample rel) |
void |
rewriteRel(Sort rel) |
void |
rewriteRel(TableScan rel) |
void |
rewriteRel(Uncollect rel) |
protected void |
setNewForOldRel(RelNode oldRel,
RelNode newRel) |
void |
updateRelInMap(SortedMap<CorrelationId,LogicalCorrelate> mapCorVarToCorRel) |
void |
updateRelInMap(com.google.common.collect.SortedSetMultimap<RelNode,CorrelationId> mapRefRelToCorVar) |
@Deprecated public RelStructuredTypeFlattener(RexBuilder rexBuilder, RelOptTable.ToRelContext toRelContext, boolean restructure)
public RelStructuredTypeFlattener(RelBuilder relBuilder, RexBuilder rexBuilder, RelOptTable.ToRelContext toRelContext, boolean restructure)
public void updateRelInMap(com.google.common.collect.SortedSetMultimap<RelNode,CorrelationId> mapRefRelToCorVar)
public void updateRelInMap(SortedMap<CorrelationId,LogicalCorrelate> mapCorVarToCorRel)
protected int getNewForOldInput(int oldOrdinal)
oldOrdinal - Pre-flattening ordinalprotected org.apache.calcite.linq4j.Ord<RelDataType> getNewFieldForOldInput(int oldOrdinal)
oldOrdinal - Pre-flattening ordinalpublic void rewriteRel(LogicalTableModify rel)
public void rewriteRel(LogicalAggregate rel)
public void rewriteRel(Sort rel)
public void rewriteRel(LogicalFilter rel)
public void rewriteRel(LogicalJoin rel)
public void rewriteRel(LogicalCorrelate rel)
public void rewriteRel(Collect rel)
public void rewriteRel(Uncollect rel)
public void rewriteRel(LogicalIntersect rel)
public void rewriteRel(LogicalMinus rel)
public void rewriteRel(LogicalUnion rel)
public void rewriteRel(LogicalValues rel)
public void rewriteRel(LogicalTableFunctionScan rel)
public void rewriteRel(Sample rel)
public void rewriteRel(LogicalProject rel)
public void rewriteRel(LogicalCalc rel)
public void rewriteRel(RelStructuredTypeFlattener.SelfFlatteningRel rel)
public void rewriteGeneric(RelNode rel)
public void rewriteRel(TableScan rel)
public void rewriteRel(LogicalSnapshot rel)
public void rewriteRel(LogicalDelta rel)
public void rewriteRel(LogicalChi rel)
public void rewriteRel(LogicalMatch rel)
Copyright © 2012-2020 Apache Software Foundation. All Rights Reserved.