C - Configuration typepublic abstract class ReduceExpressionsRule<C extends ReduceExpressionsRule.Config> extends RelRule<C> implements SubstitutionRule
| Modifier and Type | Class and Description |
|---|---|
static class |
ReduceExpressionsRule.CalcReduceExpressionsRule
Rule that reduces constants inside a
Calc. |
protected static class |
ReduceExpressionsRule.CaseShuttle
Shuttle that pushes predicates into a CASE.
|
static interface |
ReduceExpressionsRule.Config
Rule configuration.
|
static class |
ReduceExpressionsRule.FilterReduceExpressionsRule
Rule that reduces constants inside a
Filter. |
static class |
ReduceExpressionsRule.JoinReduceExpressionsRule
Rule that reduces constants inside a
Join. |
static class |
ReduceExpressionsRule.ProjectReduceExpressionsRule
Rule that reduces constants inside a
Project. |
protected static class |
ReduceExpressionsRule.ReducibleExprLocator
Helper class used to locate expressions that either can be reduced to
literals or contain redundant casts.
|
protected static class |
ReduceExpressionsRule.RexReplacer
Replaces expressions with their reductions.
|
static class |
ReduceExpressionsRule.WindowReduceExpressionsRule
Rule that reduces constants inside a
Window. |
RelRule.Done, RelRule.MatchHandler<R extends RelOptRule>, RelRule.OperandBuilder, RelRule.OperandDetailBuilder<R extends RelNode>, RelRule.OperandTransformRelOptRule.ConverterRelOptRuleOperand| Modifier and Type | Field and Description |
|---|---|
static Pattern |
EXCLUSION_PATTERN
Regular expression that matches the description of all instances of this
rule and
ValuesReduceRule also. |
description, operands, relBuilderFactory| Modifier | Constructor and Description |
|---|---|
protected |
ReduceExpressionsRule(C config)
Creates a ReduceExpressionsRule.
|
| Modifier and Type | Method and Description |
|---|---|
protected static void |
findReducibleExps(RelDataTypeFactory typeFactory,
List<RexNode> exps,
com.google.common.collect.ImmutableMap<RexNode,RexNode> constants,
List<RexNode> constExps,
List<Boolean> addCasts,
boolean treatDynamicCallsAsConstant)
Locates expressions that can be reduced to literals or converted to
expressions with redundant casts removed.
|
static <C extends RexNode> |
predicateConstants(Class<C> clazz,
RexBuilder rexBuilder,
RelOptPredicateList predicates)
Deprecated.
|
static RexCall |
pushPredicateIntoCase(RexCall call)
Pushes predicates into a CASE.
|
protected static boolean |
reduceExpressions(RelNode rel,
List<RexNode> expList,
RelOptPredicateList predicates)
Reduces a list of expressions.
|
protected static boolean |
reduceExpressions(RelNode rel,
List<RexNode> expList,
RelOptPredicateList predicates,
boolean unknownAsFalse)
Deprecated.
|
protected static boolean |
reduceExpressions(RelNode rel,
List<RexNode> expList,
RelOptPredicateList predicates,
boolean unknownAsFalse,
boolean matchNullability,
boolean treatDynamicCallsAsConstant)
Reduces a list of expressions.
|
protected static boolean |
reduceExpressionsInternal(RelNode rel,
RexSimplify simplify,
RexUnknownAs unknownAs,
List<RexNode> expList,
RelOptPredicateList predicates,
boolean treatDynamicCallsAsConstant) |
protected static RexNode |
substitute(RexCall call,
int ordinal,
RexNode node)
Converts op(arg0, ..., argOrdinal, ..., argN) to op(arg0,..., node, ..., argN).
|
any, convert, convert, convertList, convertOperand, convertOperand, equals, equals, getOperand, getOperands, getOutConvention, getOutTrait, hashCode, matches, none, onMatch, operand, operand, operand, operand, operand, operandJ, operandJ, some, toString, unorderedclone, finalize, getClass, notify, notifyAll, wait, wait, waitautoPruneOldpublic static final Pattern EXCLUSION_PATTERN
ValuesReduceRule also. Use
it to prevent the planner from invoking these rules.protected ReduceExpressionsRule(C config)
protected static boolean reduceExpressions(RelNode rel, List<RexNode> expList, RelOptPredicateList predicates)
rel - Relational expressionexpList - List of expressions, modified in placepredicates - Constraints known to hold on input expressions@Deprecated protected static boolean reduceExpressions(RelNode rel, List<RexNode> expList, RelOptPredicateList predicates, boolean unknownAsFalse)
protected static boolean reduceExpressions(RelNode rel, List<RexNode> expList, RelOptPredicateList predicates, boolean unknownAsFalse, boolean matchNullability, boolean treatDynamicCallsAsConstant)
The matchNullability flag comes into play when reducing a
expression whose type is nullable. Suppose we are reducing an expression
CASE WHEN 'a' = 'a' THEN 1 ELSE NULL END. Before reduction the
type is INTEGER (nullable), but after reduction the literal 1 has
type INTEGER NOT NULL.
In some situations it is more important to preserve types; in this
case you should use matchNullability = true (which used to be
the default behavior of this method), and it will cast the literal to
INTEGER (nullable).
In other situations, you would rather propagate the new stronger type,
because it may allow further optimizations later; pass
matchNullability = false and no cast will be added, but you may
need to adjust types elsewhere in the expression tree.
rel - Relational expressionexpList - List of expressions, modified in placepredicates - Constraints known to hold on input expressionsunknownAsFalse - Whether UNKNOWN will be treated as FALSEmatchNullability - Whether Calcite should add a CAST to a literal
resulting from simplification and expression if the
expression had nullable type and the literal is
NOT NULLtreatDynamicCallsAsConstant - Whether to treat dynamic functions as
constantsprotected static boolean reduceExpressionsInternal(RelNode rel, RexSimplify simplify, RexUnknownAs unknownAs, List<RexNode> expList, RelOptPredicateList predicates, boolean treatDynamicCallsAsConstant)
protected static void findReducibleExps(RelDataTypeFactory typeFactory, List<RexNode> exps, com.google.common.collect.ImmutableMap<RexNode,RexNode> constants, List<RexNode> constExps, List<Boolean> addCasts, boolean treatDynamicCallsAsConstant)
typeFactory - Type factoryexps - list of candidate expressions to be examined for
reductionconstants - List of expressions known to be constantconstExps - returns the list of expressions that can be constant
reducedaddCasts - indicator for each expression that can be constant
reduced, whether a cast of the resulting reduced
expression is potentially necessarytreatDynamicCallsAsConstant - Whether to treat dynamic functions as
constants@Deprecated public static <C extends RexNode> com.google.common.collect.ImmutableMap<RexNode,C> predicateConstants(Class<C> clazz, RexBuilder rexBuilder, RelOptPredicateList predicates)
RelOptPredicateList.constantMapC - what to consider a constant: RexLiteral to use a narrow
definition of constant, or RexNode to use
RexUtil.isConstant(RexNode)clazz - Class of expression that is considered constantrexBuilder - Rex builderpredicates - Predicate listpublic static RexCall pushPredicateIntoCase(RexCall call)
We have a loose definition of 'predicate': any boolean expression will do, except CASE. For example '(CASE ...) = 5' or '(CASE ...) IS NULL'.
Copyright © 2012-2022 Apache Software Foundation. All Rights Reserved.