Package org.apache.calcite.rel.rules
Class ValuesReduceRule
- java.lang.Object
-
- org.apache.calcite.plan.RelOptRule
-
- org.apache.calcite.rel.rules.ValuesReduceRule
-
public abstract class ValuesReduceRule extends RelOptRule
Planner rule that folds projections and filters into an underlyingLogicalValues
.Returns a simplified
Values
, perhaps containing zero tuples if all rows are filtered away.For example,
select a - b from (values (1, 2), (3, 5), (7, 11)) as t (a, b) where a + b > 4
becomes
select x from (values (-2), (-4))
Ignores an empty
Values
; this is better dealt with byPruneEmptyRules
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ValuesReduceRule.MyRexShuttle
Shuttle that converts inputs to literals.
-
Field Summary
Fields Modifier and Type Field Description static ValuesReduceRule
FILTER_INSTANCE
Instance of this rule that applies to the pattern Filter(Values).private static org.slf4j.Logger
LOGGER
static ValuesReduceRule
PROJECT_FILTER_INSTANCE
Singleton instance of this rule that applies to the pattern Project(Filter(Values)).static ValuesReduceRule
PROJECT_INSTANCE
Instance of this rule that applies to the pattern Project(Values).-
Fields inherited from class org.apache.calcite.plan.RelOptRule
description, operands, relBuilderFactory
-
-
Constructor Summary
Constructors Constructor Description ValuesReduceRule(RelOptRuleOperand operand, RelBuilderFactory relBuilderFactory, java.lang.String desc)
Creates a ValuesReduceRule.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
apply(RelOptRuleCall call, LogicalProject project, LogicalFilter filter, LogicalValues values)
Does the work.-
Methods inherited from class org.apache.calcite.plan.RelOptRule
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, unordered
-
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
FILTER_INSTANCE
public static final ValuesReduceRule FILTER_INSTANCE
Instance of this rule that applies to the pattern Filter(Values).
-
PROJECT_INSTANCE
public static final ValuesReduceRule PROJECT_INSTANCE
Instance of this rule that applies to the pattern Project(Values).
-
PROJECT_FILTER_INSTANCE
public static final ValuesReduceRule PROJECT_FILTER_INSTANCE
Singleton instance of this rule that applies to the pattern Project(Filter(Values)).
-
-
Constructor Detail
-
ValuesReduceRule
public ValuesReduceRule(RelOptRuleOperand operand, RelBuilderFactory relBuilderFactory, java.lang.String desc)
Creates a ValuesReduceRule.- Parameters:
operand
- Class of rels to which this rule should applyrelBuilderFactory
- Builder for relational expressionsdesc
- Description, or null to guess description
-
-
Method Detail
-
apply
protected void apply(RelOptRuleCall call, LogicalProject project, LogicalFilter filter, LogicalValues values)
Does the work.- Parameters:
call
- Rule callproject
- Project, may be nullfilter
- Filter, may be nullvalues
- Values rel to be reduced
-
-