| Modifier and Type | Class and Description |
|---|---|
static class |
RelOptUtil.InputFinder
Visitor which builds a bitmap of the inputs used by an expression.
|
static class |
RelOptUtil.InputReferencedVisitor
Shuttle that finds the set of inputs that are used.
|
static class |
RelOptUtil.Logic
Policies for handling two- and three-valued boolean logic.
|
static class |
RelOptUtil.RexInputConverter
Walks an expression tree, converting the index of RexInputRefs based on
some adjustment factor.
|
static class |
RelOptUtil.SubqueryType
What kind of sub-query.
|
static class |
RelOptUtil.TypeDumper
Converts types to descriptive strings.
|
static class |
RelOptUtil.VariableUsedVisitor
Visitor that finds all variables used in an expression.
|
| Modifier and Type | Field and Description |
|---|---|
static com.google.common.base.Predicate<Calc> |
CALC_PREDICATE
Predicate for whether a calc contains multisets or windowed
aggregates.
|
static double |
EPSILON |
static com.google.common.base.Predicate<Filter> |
FILTER_PREDICATE
Predicate for whether a filter contains multisets or windowed
aggregates.
|
static com.google.common.base.Predicate<Project> |
PROJECT_PREDICATE
Predicate for whether a project contains multisets or windowed
aggregates.
|
| Constructor and Description |
|---|
RelOptUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <T extends RelNode> |
addTrait(T rel,
RelTrait trait) |
static List<Integer> |
adjustKeys(List<Integer> keys,
int adjustment)
Adjusts key values in a list by some fixed amount.
|
static boolean |
analyzeSimpleEquiJoin(LogicalJoin join,
int[] joinFieldOrdinals) |
static RexNode |
andJoinFilters(RexBuilder rexBuilder,
RexNode left,
RexNode right)
Ands two sets of join filters together, either of which can be null.
|
static boolean |
areRowTypesEqual(RelDataType rowType1,
RelDataType rowType2,
boolean compareNames) |
static boolean |
checkProjAndChildInputs(Project project,
boolean checkNames)
Determines if a projection and its input reference identical input
references.
|
static boolean |
classifyFilters(RelNode joinRel,
List<RexNode> filters,
JoinRelType joinType,
boolean pushInto,
boolean pushLeft,
boolean pushRight,
List<RexNode> joinFilters,
List<RexNode> leftFilters,
List<RexNode> rightFilters)
Classifies filters according to where they should be processed.
|
static List<RexNode> |
conjunctions(RexNode rexPredicate)
Returns a condition decomposed by AND.
|
static boolean |
contains(RelNode ancestor,
RelNode target)
Returns whether relational expression
target occurs within a
relational expression ancestor. |
static int |
countJoins(RelNode rootRel)
Returns the number of
Join nodes in a
tree. |
static RelNode |
createCastRel(RelNode rel,
RelDataType castRowType,
boolean rename)
Creates a projection which casts a rel's output to a desired row type.
|
static RelNode |
createCastRel(RelNode rel,
RelDataType castRowType,
boolean rename,
RelFactories.ProjectFactory projectFactory)
Creates a projection which casts a rel's output to a desired row type.
|
static RelNode |
createDistinctRel(RelNode rel)
Creates a LogicalAggregate that removes all duplicates from the result of
an underlying relational expression.
|
static RelDataType |
createDmlRowType(SqlKind kind,
RelDataTypeFactory typeFactory)
Creates the row type descriptor for the result of a DML operation, which
is a single column named ROWCOUNT of type BIGINT for INSERT;
a single column named PLAN for EXPLAIN.
|
static RexNode |
createEquiJoinCondition(RelNode left,
List<Integer> leftKeys,
RelNode right,
List<Integer> rightKeys,
RexBuilder rexBuilder)
Builds an equi-join condition from a set of left and right keys.
|
static Pair<RelNode,Boolean> |
createExistsPlan(RelNode seekRel,
RelOptUtil.SubqueryType subqueryType,
RelOptUtil.Logic logic,
boolean needsOuterJoin)
Creates a plan suitable for use in
EXISTS or IN
statements. |
static RelNode |
createExistsPlan(RelOptCluster cluster,
RelNode seekRel,
List<RexNode> conditions,
RexLiteral extraExpr,
String extraName)
Creates a plan suitable for use in
EXISTS or IN
statements. |
static RelNode |
createFilter(RelNode child,
Iterable<? extends RexNode> conditions)
Creates a filter, using the default filter factory,
or returns the original relational expression if the
condition is trivial.
|
static RelNode |
createFilter(RelNode child,
Iterable<? extends RexNode> conditions,
RelFactories.FilterFactory filterFactory)
Creates a filter using the default factory,
or returns the original relational expression if the
condition is trivial.
|
static RelNode |
createFilter(RelNode child,
RexNode condition)
Creates a relational expression which filters according to a given
condition, returning the same fields as its input, using the default
filter factory.
|
static RelNode |
createFilter(RelNode child,
RexNode condition,
RelFactories.FilterFactory filterFactory)
Creates a relational expression which filters according to a given
condition, returning the same fields as its input.
|
static RelNode |
createNullFilter(RelNode rel,
Integer[] fieldOrdinals)
Creates a filter which will remove rows containing NULL values.
|
static RelNode |
createProject(RelFactories.ProjectFactory factory,
RelNode child,
List<Integer> posList)
Creates a relational expression that projects the given fields of the
input.
|
static RelNode |
createProject(RelNode child,
List<? extends RexNode> exprList,
List<String> fieldNameList)
Creates a relational expression which projects a list of expressions.
|
static RelNode |
createProject(RelNode child,
List<? extends RexNode> exprs,
List<String> fieldNames,
boolean optimize)
Creates a relational expression which projects an array of expressions,
and optionally optimizes.
|
static RelNode |
createProject(RelNode child,
List<Integer> posList)
Creates a relational expression that projects the given fields of the
input.
|
static RelNode |
createProject(RelNode child,
List<Pair<RexNode,String>> projectList,
boolean optimize)
Creates a relational expression which projects a list of (expression, name)
pairs.
|
static RelNode |
createProject(RelNode child,
Mappings.TargetMapping mapping)
Creates a
LogicalProject that
projects particular fields of its input, according to a mapping. |
static RelNode |
createProjectJoinRel(List<Integer> outputProj,
RelNode joinRel)
Creates a projection on top of a join, if the desired projection is a
subset of the join columns
|
static RelNode |
createRename(RelNode rel,
List<String> fieldNames)
Returns a relational expression which has the same fields as the
underlying expression, but the fields have different names.
|
static RelNode |
createRenameRel(RelDataType outputType,
RelNode rel)
Creates a LogicalProject which accomplishes a rename.
|
static RelNode |
createSingleValueAggRel(RelOptCluster cluster,
RelNode rel)
Creates a LogicalAggregate that removes all duplicates from the result of
an underlying relational expression.
|
static List<RexNode> |
createSwappedJoinExprs(RelNode newJoin,
Join origJoin,
boolean origOrder)
Creates projection expressions reflecting the swapping of a join's input.
|
static void |
decomposeConjunction(RexNode rexPredicate,
List<RexNode> rexList)
Decomposes a predicate into a list of expressions that are AND'ed
together.
|
static void |
decomposeConjunction(RexNode rexPredicate,
List<RexNode> rexList,
List<RexNode> notList)
Decomposes a predicate into a list of expressions that are AND'ed
together, and a list of expressions that are preceded by NOT.
|
static void |
decomposeDisjunction(RexNode rexPredicate,
List<RexNode> rexList)
Decomposes a predicate into a list of expressions that are OR'ed
together.
|
static List<RexNode> |
disjunctions(RexNode rexPredicate)
Returns a condition decomposed by OR.
|
static String |
dumpPlan(String header,
RelNode rel,
boolean asXml,
SqlExplainLevel detailLevel)
Dumps a plan as a string.
|
static String |
dumpType(RelDataType type) |
static boolean |
eq(String desc1,
RelDataType type1,
String desc2,
RelDataType type2,
boolean fail)
Returns whether two types are equal using '='.
|
static boolean |
equal(String desc1,
RelDataType type1,
String desc2,
RelDataType type2,
boolean fail)
Returns whether two types are equal using
areRowTypesEqual(RelDataType, RelDataType, boolean). |
static boolean |
equalType(String desc0,
RelNode rel0,
String desc1,
RelNode rel1,
boolean fail)
Returns whether two relational expressions have the same row-type.
|
static RelOptTable.ToRelContext |
getContext(RelOptCluster cluster)
Returns a simple
RelOptTable.ToRelContext. |
static List<RelDataType> |
getFieldTypeList(RelDataType type)
Returns a list of the types of the fields in a given struct type.
|
static Set<String> |
getVariablesSet(RelNode rel)
Returns a list of variables set by a relational expression or its
descendants.
|
static List<String> |
getVariablesSetAndUsed(RelNode rel0,
RelNode rel1)
Returns a set of distinct variables set by
rel0 and used by
rel1. |
static Set<String> |
getVariablesUsed(RelNode rel)
Returns a set of variables used by a relational expression or its
descendants.
|
static void |
go(RelVisitor visitor,
RelNode p)
Sets a
RelVisitor going on a given relational expression, and
returns the result. |
static RexNode |
isDistinctFrom(RexBuilder rexBuilder,
RexNode x,
RexNode y,
boolean neg)
Returns a translation of the
IS DISTINCT FROM (or IS
NOT DISTINCT FROM) sql operator. |
static boolean |
isEqui(RelNode left,
RelNode right,
RexNode condition)
Returns whether a join condition is an "equi-join" condition.
|
static Mappings.TargetMapping |
permutation(List<RexNode> nodes,
RelDataType inputRowType)
Returns a permutation describing where output fields come from.
|
static RelDataType |
permute(RelDataTypeFactory typeFactory,
RelDataType rowType,
Mapping mapping)
Permutes a record type according to a mapping.
|
static RelNode |
permute(RelNode rel,
Permutation permutation,
List<String> fieldNames)
Creates a relational expression which permutes the output fields of a
relational expression according to a permutation.
|
static void |
projectJoinInputs(RelNode[] inputRels,
List<RexNode> leftJoinKeys,
List<RexNode> rightJoinKeys,
int systemColCount,
List<Integer> leftKeys,
List<Integer> rightKeys,
List<Integer> outputProj)
Adding projection to the inputs of a join to produce the required join
keys.
|
static RelNode |
projectMapping(RelNode rel,
Mapping mapping,
List<String> fieldNames,
RelFactories.ProjectFactory projectFactory)
Creates a relational expression which projects the output fields of a
relational expression according to a partial mapping.
|
static MultiJoin |
projectMultiJoin(MultiJoin multiJoin,
LogicalProject project)
Creates a new
MultiJoin to reflect
projection references from a
LogicalProject that is on top of the
MultiJoin. |
static RexNode |
pushFilterPastProject(RexNode filter,
Project projRel)
Converts a filter to the new filter that would result if the filter is
pushed past a LogicalProject that it currently is referencing.
|
static void |
registerAbstractRels(RelOptPlanner planner) |
static RelNode |
renameIfNecessary(RelNode rel,
RelDataType desiredRowType)
Renames a relational expression to make its field names the same as
another row type.
|
static RelNode |
replace(RelNode query,
RelNode find,
RelNode replace)
Within a relational expression
query, replaces occurrences of
find with replace. |
static RelNode |
replaceInput(RelNode parent,
int ordinal,
RelNode newInput)
Returns a shallow copy of a relational expression with a particular
input replaced.
|
static JoinRelType |
simplifyJoin(RelNode joinRel,
com.google.common.collect.ImmutableList<RexNode> aboveFilters,
JoinRelType joinType)
Simplifies outer joins if filter above would reject nulls.
|
static RexNode |
splitCorrelatedFilterCondition(LogicalFilter filter,
List<RexInputRef> joinKeys,
List<RexNode> correlatedJoinKeys) |
static RexNode |
splitCorrelatedFilterCondition(LogicalFilter filter,
List<RexNode> joinKeys,
List<RexNode> correlatedJoinKeys,
boolean extractCorrelatedFieldAccess) |
static void |
splitFilters(ImmutableBitSet childBitmap,
RexNode predicate,
List<RexNode> pushable,
List<RexNode> notPushable)
Splits a filter into two lists, depending on whether or not the filter
only references its child input
|
static RexNode |
splitJoinCondition(List<RelDataTypeField> sysFieldList,
List<RelNode> inputs,
RexNode condition,
List<List<RexNode>> joinKeys,
List<Integer> filterNulls,
List<SqlOperator> rangeOp)
Splits out the equi-join (and optionally, a single non-equi) components
of a join condition, and returns what's left.
|
static RexNode |
splitJoinCondition(List<RelDataTypeField> sysFieldList,
RelNode leftRel,
RelNode rightRel,
RexNode condition,
List<RexNode> leftJoinKeys,
List<RexNode> rightJoinKeys,
List<Integer> filterNulls,
List<SqlOperator> rangeOp)
Splits out the equi-join (and optionally, a single non-equi) components
of a join condition, and returns what's left.
|
static RexNode |
splitJoinCondition(RelNode left,
RelNode right,
RexNode condition,
List<Integer> leftKeys,
List<Integer> rightKeys)
Splits out the equi-join components of a join condition, and returns
what's left.
|
static String |
toString(RelNode rel)
Converts a relational expression to a string, showing just basic
attributes.
|
static String |
toString(RelNode rel,
SqlExplainLevel detailLevel)
Converts a relational expression to a string.
|
static void |
verifyTypeEquivalence(RelNode originalRel,
RelNode newRel,
Object equivalenceClass)
Verifies that a row type being added to an equivalence class matches the
existing type, raising an assertion if this is not the case.
|
public static final double EPSILON
public static final com.google.common.base.Predicate<Filter> FILTER_PREDICATE
public static final com.google.common.base.Predicate<Project> PROJECT_PREDICATE
public static final com.google.common.base.Predicate<Calc> CALC_PREDICATE
public static Set<String> getVariablesSet(RelNode rel)
public static List<String> getVariablesSetAndUsed(RelNode rel0, RelNode rel1)
rel0 and used by
rel1.public static Set<String> getVariablesUsed(RelNode rel)
RexVariable.getName()public static void go(RelVisitor visitor, RelNode p)
RelVisitor going on a given relational expression, and
returns the result.public static List<RelDataType> getFieldTypeList(RelDataType type)
type - Struct typeRelDataType.getFieldNames()public static boolean areRowTypesEqual(RelDataType rowType1, RelDataType rowType2, boolean compareNames)
public static void verifyTypeEquivalence(RelNode originalRel, RelNode newRel, Object equivalenceClass)
originalRel - canonical rel for equivalence classnewRel - rel being added to equivalence classequivalenceClass - object representing equivalence classpublic static Mappings.TargetMapping permutation(List<RexNode> nodes, RelDataType inputRowType)
map.getTargetOpt(i) is n if
field i projects input field n, -1 if it is an
expression.public static RelNode createExistsPlan(RelOptCluster cluster, RelNode seekRel, List<RexNode> conditions, RexLiteral extraExpr, String extraName)
EXISTS or IN
statements.
Note: this implementation of createExistsPlan is only called from net.sf.farrago.fennel.rel. The last two arguments do not apply to those invocations and can be removed from the method.
cluster - ClusterseekRel - A query rel, for example the resulting rel from 'select *
from emp' or 'values (1,2,3)' or '('Foo', 34)'.conditions - May be nullextraExpr - Column expression to add. "TRUE" for EXISTS and INextraName - Name of expression to add.public static Pair<RelNode,Boolean> createExistsPlan(RelNode seekRel, RelOptUtil.SubqueryType subqueryType, RelOptUtil.Logic logic, boolean needsOuterJoin)
EXISTS or IN
statements.seekRel - A query rel, for example the resulting rel from 'select *
from emp' or 'values (1,2,3)' or '('Foo', 34)'.subqueryType - Sub-query typelogic - Whether to use 2- or 3-valued boolean logicneedsOuterJoin - Whether query needs outer joinSqlToRelConverter.convertExists(org.apache.calcite.sql.SqlNode, org.apache.calcite.plan.RelOptUtil.SubqueryType, org.apache.calcite.plan.RelOptUtil.Logic, boolean)public static RelNode createRenameRel(RelDataType outputType, RelNode rel)
outputType - a row type descriptor whose field names the generated
LogicalProject must matchrel - the rel whose output is to be renamed; rel.getRowType()
must be the same as outputType except for field namespublic static RelNode createFilter(RelNode child, RexNode condition)
child - Child relational expressioncondition - Conditionpublic static RelNode createFilter(RelNode child, RexNode condition, RelFactories.FilterFactory filterFactory)
child - Child relational expressioncondition - ConditionfilterFactory - Filter factorypublic static RelNode createFilter(RelNode child, Iterable<? extends RexNode> conditions)
public static RelNode createFilter(RelNode child, Iterable<? extends RexNode> conditions, RelFactories.FilterFactory filterFactory)
public static RelNode createNullFilter(RelNode rel, Integer[] fieldOrdinals)
rel - the rel to be filteredfieldOrdinals - array of 0-based field ordinals to filter, or null
for all fieldspublic static RelNode createCastRel(RelNode rel, RelDataType castRowType, boolean rename)
rel - producer of rows to be convertedcastRowType - row type after castrename - if true, use field names from castRowType; if false,
preserve field names from relpublic static RelNode createCastRel(RelNode rel, RelDataType castRowType, boolean rename, RelFactories.ProjectFactory projectFactory)
rel - producer of rows to be convertedcastRowType - row type after castrename - if true, use field names from castRowType; if false,
preserve field names from relprojectFactory - Project Factorypublic static RelNode createSingleValueAggRel(RelOptCluster cluster, RelNode rel)
rel - underlying relpublic static RelNode createDistinctRel(RelNode rel)
rel - underlying relpublic static boolean analyzeSimpleEquiJoin(LogicalJoin join, int[] joinFieldOrdinals)
public static RexNode splitJoinCondition(RelNode left, RelNode right, RexNode condition, List<Integer> leftKeys, List<Integer> rightKeys)
L.A = R.X AND L.B = L.C AND (L.D = 5 OR L.E =
R.Y)
returns
left - left input to joinright - right input to joincondition - join conditionleftKeys - The ordinals of the fields from the left input which are
equi-join keysrightKeys - The ordinals of the fields from the right input which
are equi-join keysRexLiteral true, but never nullpublic static boolean isEqui(RelNode left, RelNode right, RexNode condition)
left - Left input of joinright - Right input of joincondition - Conditionpublic static RexNode splitJoinCondition(List<RelDataTypeField> sysFieldList, RelNode leftRel, RelNode rightRel, RexNode condition, List<RexNode> leftJoinKeys, List<RexNode> rightJoinKeys, List<Integer> filterNulls, List<SqlOperator> rangeOp)
sysFieldList - list of system fieldsleftRel - left join inputrightRel - right join inputcondition - join conditionleftJoinKeys - The join keys from the left input which are equi-join
keysrightJoinKeys - The join keys from the right input which are
equi-join keysfilterNulls - The join key positions for which null values will not
match. null values only match for the "is not distinct
from" condition.rangeOp - if null, only locate equi-joins; otherwise, locate a
single non-equi join predicate and return its operator
in this list; join keys associated with the non-equi
join predicate are at the end of the key lists
returnedpublic static RexNode splitJoinCondition(List<RelDataTypeField> sysFieldList, List<RelNode> inputs, RexNode condition, List<List<RexNode>> joinKeys, List<Integer> filterNulls, List<SqlOperator> rangeOp)
sysFieldList - list of system fieldsinputs - join inputscondition - join conditionjoinKeys - The join keys from the inputs which are equi-join
keysfilterNulls - The join key positions for which null values will not
match. null values only match for the "is not distinct
from" condition.rangeOp - if null, only locate equi-joins; otherwise, locate a
single non-equi join predicate and return its operator
in this list; join keys associated with the non-equi
join predicate are at the end of the key lists
returnedpublic static RexNode splitCorrelatedFilterCondition(LogicalFilter filter, List<RexInputRef> joinKeys, List<RexNode> correlatedJoinKeys)
public static RexNode splitCorrelatedFilterCondition(LogicalFilter filter, List<RexNode> joinKeys, List<RexNode> correlatedJoinKeys, boolean extractCorrelatedFieldAccess)
public static RexNode createEquiJoinCondition(RelNode left, List<Integer> leftKeys, RelNode right, List<Integer> rightKeys, RexBuilder rexBuilder)
public static void projectJoinInputs(RelNode[] inputRels, List<RexNode> leftJoinKeys, List<RexNode> rightJoinKeys, int systemColCount, List<Integer> leftKeys, List<Integer> rightKeys, List<Integer> outputProj)
inputRels - inputs to a joinleftJoinKeys - expressions for LHS of join keyrightJoinKeys - expressions for RHS of join keysystemColCount - number of system columns, usually zero. These
columns are projected at the leading edge of the
output row.leftKeys - on return this contains the join key positions from
the new project rel on the LHS.rightKeys - on return this contains the join key positions from
the new project rel on the RHS.outputProj - on return this contains the positions of the original
join output in the (to be formed by caller)
LhxJoinRel. Caller needs to be responsible for adding
projection on the new join output.public static RelNode createProjectJoinRel(List<Integer> outputProj, RelNode joinRel)
outputProj - desired projection; if null, return original join nodejoinRel - the join nodepublic static void registerAbstractRels(RelOptPlanner planner)
public static String dumpPlan(String header, RelNode rel, boolean asXml, SqlExplainLevel detailLevel)
header - Header to print before the plan. Ignored if the format
is XML.rel - Relational expression to explain.asXml - Whether to format as XML.detailLevel - Detail level.public static RelDataType createDmlRowType(SqlKind kind, RelDataTypeFactory typeFactory)
kind - Kind of nodetypeFactory - factory to use for creating type descriptorpublic static boolean eq(String desc1, RelDataType type1, String desc2, RelDataType type2, boolean fail)
desc1 - Description of first typetype1 - First typedesc2 - Description of second typetype2 - Second typefail - Whether to assert if they are not equalpublic static boolean equal(String desc1, RelDataType type1, String desc2, RelDataType type2, boolean fail)
areRowTypesEqual(RelDataType, RelDataType, boolean). Both types
must not be null.desc1 - Description of role of first typetype1 - First typedesc2 - Description of role of second typetype2 - Second typefail - Whether to assert if they are not equalpublic static boolean equalType(String desc0, RelNode rel0, String desc1, RelNode rel1, boolean fail)
public static RexNode isDistinctFrom(RexBuilder rexBuilder, RexNode x, RexNode y, boolean neg)
IS DISTINCT FROM (or IS
NOT DISTINCT FROM) sql operator.neg - if false, returns a translation of IS NOT DISTINCT FROMpublic static String toString(RelNode rel)
public static String toString(RelNode rel, SqlExplainLevel detailLevel)
public static RelNode renameIfNecessary(RelNode rel, RelDataType desiredRowType)
rel - Relational expressiondesiredRowType - Desired row type (including desired field names)public static String dumpType(RelDataType type)
public static void decomposeConjunction(RexNode rexPredicate, List<RexNode> rexList)
rexPredicate - predicate to be analyzedrexList - list of decomposed RexNodespublic static void decomposeConjunction(RexNode rexPredicate, List<RexNode> rexList, List<RexNode> notList)
For example, a AND NOT b AND NOT (c and d) AND TRUE AND NOT
FALSE returns rexList = [a], notList = [b, c AND d].
TRUE and NOT FALSE expressions are ignored. FALSE and NOT TRUE
expressions are placed on rexList and notList as other
expressions.
For example, a AND TRUE AND NOT TRUE returns
rexList = [a], notList = [TRUE].
rexPredicate - predicate to be analyzedrexList - list of decomposed RexNodes (except those with NOT)notList - list of decomposed RexNodes that were prefixed NOTpublic static void decomposeDisjunction(RexNode rexPredicate, List<RexNode> rexList)
rexPredicate - predicate to be analyzedrexList - list of decomposed RexNodespublic static List<RexNode> conjunctions(RexNode rexPredicate)
For example, conjunctions(TRUE) returns the empty list;
conjunctions(FALSE) returns list {FALSE}.
public static List<RexNode> disjunctions(RexNode rexPredicate)
For example, disjunctions(FALSE) returns the empty list.
public static RexNode andJoinFilters(RexBuilder rexBuilder, RexNode left, RexNode right)
rexBuilder - rexBuilder to create AND expressionleft - filter on the left that the right will be AND'd toright - filter on the rightRexUtil.composeConjunction(org.apache.calcite.rex.RexBuilder, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, boolean)public static List<Integer> adjustKeys(List<Integer> keys, int adjustment)
keys - list of key valuesadjustment - the amount to adjust the key values bypublic static JoinRelType simplifyJoin(RelNode joinRel, com.google.common.collect.ImmutableList<RexNode> aboveFilters, JoinRelType joinType)
joinRel - JoinaboveFilters - Filters from abovejoinType - Join type, can not be inner joinpublic static boolean classifyFilters(RelNode joinRel, List<RexNode> filters, JoinRelType joinType, boolean pushInto, boolean pushLeft, boolean pushRight, List<RexNode> joinFilters, List<RexNode> leftFilters, List<RexNode> rightFilters)
joinRel - join nodefilters - filters to be classifiedjoinType - join typepushInto - whether filters can be pushed into the ON clausepushLeft - true if filters can be pushed to the leftpushRight - true if filters can be pushed to the rightjoinFilters - list of filters to push to the joinleftFilters - list of filters to push to the left childrightFilters - list of filters to push to the right childpublic static void splitFilters(ImmutableBitSet childBitmap, RexNode predicate, List<RexNode> pushable, List<RexNode> notPushable)
childBitmap - Fields in the childpredicate - filters that will be splitpushable - returns the list of filters that can be pushed to the
child inputnotPushable - returns the list of filters that cannot be pushed to
the child inputpublic static boolean checkProjAndChildInputs(Project project, boolean checkNames)
project - projection being examinedcheckNames - if true, also compare that the names of the project
fields and its child fieldspublic static List<RexNode> createSwappedJoinExprs(RelNode newJoin, Join origJoin, boolean origOrder)
newJoin - the RelNode corresponding to the join with its inputs
swappedorigJoin - original LogicalJoinorigOrder - if true, create the projection expressions to reflect
the original (pre-swapped) join projection; otherwise,
create the projection to reflect the order of the swapped
projectionpublic static RexNode pushFilterPastProject(RexNode filter, Project projRel)
filter - the filter to be convertedprojRel - project rel underneath the filterpublic static MultiJoin projectMultiJoin(MultiJoin multiJoin, LogicalProject project)
MultiJoin to reflect
projection references from a
LogicalProject that is on top of the
MultiJoin.multiJoin - the original MultiJoinproject - the LogicalProject on top of the MultiJoinpublic static RelNode replaceInput(RelNode parent, int ordinal, RelNode newInput)
public static RelNode createProject(RelNode child, Mappings.TargetMapping mapping)
LogicalProject that
projects particular fields of its input, according to a mapping.public static boolean contains(RelNode ancestor, RelNode target)
target occurs within a
relational expression ancestor.public static RelNode replace(RelNode query, RelNode find, RelNode replace)
query, replaces occurrences of
find with replace.public static RelOptTable.ToRelContext getContext(RelOptCluster cluster)
RelOptTable.ToRelContext.public static int countJoins(RelNode rootRel)
Join nodes in a
tree.public static RelDataType permute(RelDataTypeFactory typeFactory, RelDataType rowType, Mapping mapping)
public static RelNode createProject(RelNode child, List<? extends RexNode> exprList, List<String> fieldNameList)
child - input relational expressionexprList - list of expressions for the input columnsfieldNameList - aliases of the expressions, or null to generatepublic static RelNode createProject(RelNode child, List<Pair<RexNode,String>> projectList, boolean optimize)
child - input relational expressionprojectList - list of (expression, name) pairsoptimize - Whether to optimizepublic static RelNode createProject(RelNode child, List<Integer> posList)
Optimizes if the fields are the identity projection.
child - Input relational expressionposList - Source of each projected fieldpublic static RelNode createProject(RelNode child, List<? extends RexNode> exprs, List<String> fieldNames, boolean optimize)
The result may not be a
LogicalProject. If the
projection is trivial, child is returned directly; and future
versions may return other formulations of expressions, such as
LogicalCalc.
child - input relational expressionexprs - list of expressions for the input columnsfieldNames - aliases of the expressions, or null to generateoptimize - Whether to return child unchanged if the
projections are trivial.public static RelNode createRename(RelNode rel, List<String> fieldNames)
rel - Relational expressionfieldNames - Field namespublic static RelNode permute(RelNode rel, Permutation permutation, List<String> fieldNames)
Optimizations:
LogicalCalc or
LogicalProject that is already
acting as a permutation, combines the new permutation with the old;If a permutation is combined with its inverse, these optimizations would combine to remove them both.
rel - Relational expressionpermutation - Permutation to apply to fieldsfieldNames - Field names; if null, or if a particular entry is null,
the name of the permuted field is usedpublic static RelNode createProject(RelFactories.ProjectFactory factory, RelNode child, List<Integer> posList)
Optimizes if the fields are the identity projection.
factory - ProjectFactorychild - Input relational expressionposList - Source of each projected fieldpublic static RelNode projectMapping(RelNode rel, Mapping mapping, List<String> fieldNames, RelFactories.ProjectFactory projectFactory)
A partial mapping is weaker than a permutation: every target has one source, but a source may have 0, 1 or more than one targets. Usually the result will have fewer fields than the source, unless some source fields are projected multiple times.
This method could optimize the result as permute(org.apache.calcite.rel.type.RelDataTypeFactory, org.apache.calcite.rel.type.RelDataType, org.apache.calcite.util.mapping.Mapping) does, but
does not at present.
rel - Relational expressionmapping - Mapping from source fields to target fields. The mapping
type must obey the constraints
MappingType.isMandatorySource()
and
MappingType.isSingleSource(),
as does
MappingType.INVERSE_FUNCTION.fieldNames - Field names; if null, or if a particular entry is null,
the name of the permuted field is usedCopyright © 2012–2015 The Apache Software Foundation. All rights reserved.