Package org.apache.calcite.rel.rules
Class ReduceDecimalsRule
- java.lang.Object
-
- org.apache.calcite.plan.RelOptRule
-
- org.apache.calcite.rel.rules.ReduceDecimalsRule
-
public class ReduceDecimalsRule extends RelOptRule
ReduceDecimalsRule is a rule which reduces decimal operations (such as casts or arithmetic) into operations involving more primitive types (such as longs and doubles). The rule allows Calcite implementations to deal with decimals in a consistent manner, while saving the effort of implementing them.The rule can be applied to a
LogicalCalc
with a program for whichRexUtil.requiresDecimalExpansion(org.apache.calcite.rex.RexNode, boolean)
returns true. The rule relies on aRexShuttle
to walk over relational expressions and replace them.While decimals are generally not implemented by the Calcite runtime, the rule is optionally applied, in order to support the situation in which we would like to push down decimal operations to an external database.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
ReduceDecimalsRule.BinaryArithmeticExpander
Expands a decimal arithmetic expressionprivate class
ReduceDecimalsRule.CaseExpander
Expander that rewrites case expressions, in place.private class
ReduceDecimalsRule.CastArgAsDoubleExpander
An expander which casts decimal arguments as doublesprivate class
ReduceDecimalsRule.CastArgAsTypeExpander
An expander which casts decimal arguments as another typeprivate class
ReduceDecimalsRule.CastExpander
Expands a decimal cast expressionprivate class
ReduceDecimalsRule.CeilExpander
Expander that rewrites ceiling(decimal) expressions:class
ReduceDecimalsRule.DecimalShuttle
A shuttle which converts decimal expressions to expressions based on longs.private class
ReduceDecimalsRule.ExpanderMap
Maps a RexCall to a RexExpanderprivate class
ReduceDecimalsRule.FloorExpander
Expander that rewrites floor(decimal) expressions:private class
ReduceDecimalsRule.PassThroughExpander
An expander that substitutes decimals with their integer representations.private class
ReduceDecimalsRule.ReinterpretExpander
This expander simplifies reinterpret calls.class
ReduceDecimalsRule.RexExpander
Rewrites a decimal expression for a specific set of SqlOperator's.
-
Field Summary
Fields Modifier and Type Field Description static ReduceDecimalsRule
INSTANCE
-
Fields inherited from class org.apache.calcite.plan.RelOptRule
description, operands, relBuilderFactory
-
-
Constructor Summary
Constructors Constructor Description ReduceDecimalsRule(RelBuilderFactory relBuilderFactory)
Creates a ReduceDecimalsRule.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Convention
getOutConvention()
Returns the convention of the result of firing this rule, null if not known.void
onMatch(RelOptRuleCall call)
Receives notification about a rule match.-
Methods inherited from class org.apache.calcite.plan.RelOptRule
any, convert, convert, convertList, convertOperand, convertOperand, equals, equals, getOperand, getOperands, getOutTrait, hashCode, matches, none, operand, operand, operand, operand, operand, operandJ, operandJ, some, toString, unordered
-
-
-
-
Field Detail
-
INSTANCE
public static final ReduceDecimalsRule INSTANCE
-
-
Constructor Detail
-
ReduceDecimalsRule
public ReduceDecimalsRule(RelBuilderFactory relBuilderFactory)
Creates a ReduceDecimalsRule.
-
-
Method Detail
-
getOutConvention
public Convention getOutConvention()
Description copied from class:RelOptRule
Returns the convention of the result of firing this rule, null if not known.- Overrides:
getOutConvention
in classRelOptRule
- Returns:
- Convention of the result of firing this rule, null if not known
-
onMatch
public void onMatch(RelOptRuleCall call)
Description copied from class:RelOptRule
Receives notification about a rule match. At the time that this method is called,call.rels
holds the set of relational expressions which match the operands to the rule;call.rels[0]
is the root expression.Typically a rule would check that the nodes are valid matches, creates a new expression, then calls back
RelOptRuleCall.transformTo(org.apache.calcite.rel.RelNode, java.util.Map<org.apache.calcite.rel.RelNode, org.apache.calcite.rel.RelNode>)
to register the expression.- Specified by:
onMatch
in classRelOptRule
- Parameters:
call
- Rule call- See Also:
RelOptRule.matches(RelOptRuleCall)
-
-