public abstract class HiveReduceExpressionsRule
extends org.apache.calcite.plan.RelOptRule
Modifier and Type | Class and Description |
---|---|
protected static class |
HiveReduceExpressionsRule.CaseShuttle
Shuttle that pushes predicates into a CASE.
|
static class |
HiveReduceExpressionsRule.FilterReduceExpressionsRule
Rule that reduces constants inside a
Filter . |
static class |
HiveReduceExpressionsRule.JoinReduceExpressionsRule
Rule that reduces constants inside a
org.apache.calcite.rel.core.HiveJoin . |
static class |
HiveReduceExpressionsRule.ProjectReduceExpressionsRule
Rule that reduces constants inside a
Project . |
protected static class |
HiveReduceExpressionsRule.ReducibleExprLocator
Helper class used to locate expressions that either can be reduced to
literals or contain redundant casts.
|
protected static class |
HiveReduceExpressionsRule.RexReplacer
Replaces expressions with their reductions.
|
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. |
static HiveReduceExpressionsRule |
FILTER_INSTANCE
Singleton rule that reduces constants inside a
org.apache.calcite.rel.logical.HiveFilter . |
static HiveReduceExpressionsRule |
JOIN_INSTANCE
Singleton rule that reduces constants inside a
org.apache.calcite.rel.core.HiveJoin . |
protected static org.slf4j.Logger |
LOG |
static HiveReduceExpressionsRule |
PROJECT_INSTANCE
Singleton rule that reduces constants inside a
org.apache.calcite.rel.logical.HiveProject . |
Modifier | Constructor and Description |
---|---|
protected |
HiveReduceExpressionsRule(Class<? extends org.apache.calcite.rel.RelNode> clazz,
org.apache.calcite.tools.RelBuilderFactory relBuilderFactory,
String desc)
Creates a HiveReduceExpressionsRule.
|
Modifier and Type | Method and Description |
---|---|
protected static void |
findReducibleExps(org.apache.calcite.rel.type.RelDataTypeFactory typeFactory,
List<org.apache.calcite.rex.RexNode> exps,
com.google.common.collect.ImmutableMap<org.apache.calcite.rex.RexNode,org.apache.calcite.rex.RexNode> constants,
List<org.apache.calcite.rex.RexNode> constExps,
List<Boolean> addCasts,
List<org.apache.calcite.rex.RexNode> removableCasts)
Locates expressions that can be reduced to literals or converted to
expressions with redundant casts removed.
|
static <C extends org.apache.calcite.rex.RexNode> |
predicateConstants(Class<C> clazz,
org.apache.calcite.rex.RexBuilder rexBuilder,
org.apache.calcite.plan.RelOptPredicateList predicates)
Creates a map containing each (e, constant) pair that occurs within
a predicate list.
|
protected static org.apache.calcite.rex.RexCall |
pushPredicateIntoCase(org.apache.calcite.rex.RexCall call)
Pushes predicates into a CASE.
|
protected static boolean |
reduceExpressions(org.apache.calcite.rel.RelNode rel,
List<org.apache.calcite.rex.RexNode> expList,
org.apache.calcite.plan.RelOptPredicateList predicates)
Reduces a list of expressions.
|
protected static boolean |
reduceExpressions(org.apache.calcite.rel.RelNode rel,
List<org.apache.calcite.rex.RexNode> expList,
org.apache.calcite.plan.RelOptPredicateList predicates,
boolean unknownAsFalse)
Reduces a list of expressions.
|
protected static boolean |
reduceExpressionsInternal(org.apache.calcite.rel.RelNode rel,
List<org.apache.calcite.rex.RexNode> expList,
org.apache.calcite.plan.RelOptPredicateList predicates) |
protected static org.apache.calcite.rex.RexNode |
substitute(org.apache.calcite.rex.RexCall call,
int ordinal,
org.apache.calcite.rex.RexNode node)
Converts op(arg0, ..., argOrdinal, ..., argN) to op(arg0,..., node, ..., argN).
|
protected static final org.slf4j.Logger LOG
public static final Pattern EXCLUSION_PATTERN
ValuesReduceRule
also. Use
it to prevent the planner from invoking these rules.public static final HiveReduceExpressionsRule FILTER_INSTANCE
org.apache.calcite.rel.logical.HiveFilter
.public static final HiveReduceExpressionsRule PROJECT_INSTANCE
org.apache.calcite.rel.logical.HiveProject
.public static final HiveReduceExpressionsRule JOIN_INSTANCE
org.apache.calcite.rel.core.HiveJoin
.protected static boolean reduceExpressions(org.apache.calcite.rel.RelNode rel, List<org.apache.calcite.rex.RexNode> expList, org.apache.calcite.plan.RelOptPredicateList predicates)
rel
- Relational expressionexpList
- List of expressions, modified in placepredicates
- Constraints known to hold on input expressionsprotected static boolean reduceExpressions(org.apache.calcite.rel.RelNode rel, List<org.apache.calcite.rex.RexNode> expList, org.apache.calcite.plan.RelOptPredicateList predicates, boolean unknownAsFalse)
rel
- Relational expressionexpList
- List of expressions, modified in placepredicates
- Constraints known to hold on input expressionsunknownAsFalse
- Whether UNKNOWN will be treated as FALSEprotected static boolean reduceExpressionsInternal(org.apache.calcite.rel.RelNode rel, List<org.apache.calcite.rex.RexNode> expList, org.apache.calcite.plan.RelOptPredicateList predicates)
protected static void findReducibleExps(org.apache.calcite.rel.type.RelDataTypeFactory typeFactory, List<org.apache.calcite.rex.RexNode> exps, com.google.common.collect.ImmutableMap<org.apache.calcite.rex.RexNode,org.apache.calcite.rex.RexNode> constants, List<org.apache.calcite.rex.RexNode> constExps, List<Boolean> addCasts, List<org.apache.calcite.rex.RexNode> removableCasts)
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 necessaryremovableCasts
- returns the list of cast expressions where the castpublic static <C extends org.apache.calcite.rex.RexNode> com.google.common.collect.ImmutableMap<org.apache.calcite.rex.RexNode,C> predicateConstants(Class<C> clazz, org.apache.calcite.rex.RexBuilder rexBuilder, org.apache.calcite.plan.RelOptPredicateList predicates)
C
- 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 listprotected static org.apache.calcite.rex.RexCall pushPredicateIntoCase(org.apache.calcite.rex.RexCall call)
We have a loose definition of 'predicate': any boolean expression will do, except CASE. For example '(CASE ...) = 5' or '(CASE ...) IS NULL'.
protected static org.apache.calcite.rex.RexNode substitute(org.apache.calcite.rex.RexCall call, int ordinal, org.apache.calcite.rex.RexNode node)
Copyright © 2016 The Apache Software Foundation. All rights reserved.