Package org.apache.calcite.rel.rules
package org.apache.calcite.rel.rules
Provides a core set of planner rules.
Consider this package to be the "standard library" of planner rules. Most of the common rewrites that you would want to perform on logical relational expressions, or generically on any data source, are present, and have been well tested.
Of course, the library is never complete, and contributions are welcome.
Not present are rules specific to a particular data source: look in that data source's adapter.
Also out of the scope of this package are rules that support a particular operation, such as decorrelation or recognizing materialized views. Those are defined along with the algorithm.
For
Related packages and classes
- Package
org.apache.calcite.sql
is an object model for SQL expressions - Package
org.apache.calcite.rex
is an object model for relational row expressions - Package
org.apache.calcite.plan
provides an optimizer interface.
-
ClassDescriptionRule configuration.Rule that converts CASE-style filtered aggregates into true filtered aggregates.Rule configuration.Planner rule that expands distinct aggregates (such as
COUNT(DISTINCT x)
) from aAggregate
.Rule configuration.Planner rule that rewrites anAggregate
that containsWITHIN DISTINCT
aggregate functions.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Planner rule that removes constant keys from anAggregate
.Rule configuration.Variant ofAggregateStarTableRule
that accepts aProject
between theAggregate
and itsStarTable.StarTableScan
input.Rule configuration.Planner rule that reduces aggregate functions inAggregate
s to simpler forms.Rule configuration.Planner rule that removes aAggregate
if it computes no aggregate functions (that is, it is implementingSELECT DISTINCT
), or all the aggregate functions are splittable, and the underlying relational expression is already distinct.Rule configuration.Planner rule that matches anAggregate
on top of aStarTable.StarTableScan
.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Type of relational expression.Planner rule that removes a trivialLogicalCalc
.Rule configuration.Rule configuration.CoerceInputsRule pre-casts inputs to a particular type.Rule configuration.Rules that perform logical transformations on relational expressions.Collection of planner rules that convertEXTRACT(timeUnit FROM dateTime) = constant
,FLOOR(dateTime to timeUnit
= constant} andCEIL(dateTime to timeUnit
= constant} todateTime BETWEEN lower AND upper
.Rule that converts EXTRACT, FLOOR and CEIL in aFilter
into a date range.Rule configuration.Deprecated.Planner rule that removes keys from aExchange
if those keys are known to be constant.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Planner rule that matches aFilter
expression with correlated variables, and rewrites the condition in a simpler form that is more convenient for the decorrelation logic.Rule configuration.FilterJoinRule<C extends FilterJoinRule.Config>Planner rule that pushes filters above and within a join node into the join node and/or its children nodes.Rule configuration.Rule that tries to push filter expressions into a join condition and into the inputs of the join.Rule configuration.Rule that pushes parts of the join condition to its inputs.Rule configuration.Predicate that returns whether a filter is valid in the ON clause of a join for this particular kind of join.Planner rule that combines twoLogicalFilter
s.Rule configuration.Rule configuration.Rule configuration.Planner rule that replacesIS NOT DISTINCT FROM
in aFilter
with logically equivalent operations.Rule configuration.Rule configuration.Rule configuration.Planner rule that pushes aLogicalFilter
past aLogicalTableFunctionScan
.Rule configuration.Planner rule that converts aFilter
on aTableScan
of aFilterableTable
or aProjectableFilterableTable
to aBindables.BindableTableScan
.Rule configuration.Planner rule that converts aLogicalFilter
to aLogicalCalc
.Rule configuration.Rule configuration.Rule configuration.Rule to add a semi-join into a join.Rule configuration.Planner rule that changes a join based on the associativity rule.Rule configuration.Planner rule that permutes the inputs to aJoin
.Rule configuration.Rule configuration.Rule configuration.Planner rule that matches aJoin
one of whose inputs is aLogicalProject
, and pulls the project up.Rule configuration.Planner rule that pushes down expressions in "equal" join condition.Rule configuration.Rule that pushes the right input of a join into through the left input of the join, provided that the left input is also a join.Rule configuration.Rule configuration.Rule that converts aJoin
into aLogicalCorrelate
, which can then be implemented using nested loops.Rule configuration.Planner rule to flatten a tree ofLogicalJoin
s into a singleMultiJoin
with N inputs.Rule configuration.Rule configuration.Utility class used to store aJoin
tree and the factors that make up the tree.Simple binary tree class that stores an id in the leaf nodes and keeps track of the parent LoptJoinTree object associated with the binary tree.Binary tree node that has no children.Binary tree node that has two children.Utility class that keeps track of the join factors that make up aMultiJoin
.Planner rule that implements the heuristic planner for determining optimal join orderings.Rule configuration.Implements the logic for determining the optimal semi-joins to be used in processing joins in a query.Planner rule that converts aLogicalMatch
to the result of callingLogicalMatch.copy(org.apache.calcite.plan.RelTraitSet, java.util.List<org.apache.calcite.rel.RelNode>)
.Rule configuration.Rule configuration.Collection of planner rules that deal with measures.Rule that matches anAggregate
with at least one call toSqlInternalOperators.AGG_M2V
and expands these calls by asking the measure for its expression.Configuration forMeasureRules.AggregateMeasure2Rule
.Rule that matches anAggregate
with at least one call toSqlInternalOperators.AGG_M2V
and converts those calls toSqlInternalOperators.M2X
.Configuration forMeasureRules.AggregateMeasureRule
.Configuration forMeasureRules.FilterSortMeasureRule
.Configuration forMeasureRules.ProjectMeasureRule
.Configuration forMeasureRules.ProjectSortMeasureRule
.Rule configuration.A MultiJoin represents a join of N inputs, whereas regular Joins represent strictly binary joins.Planner rule that finds an approximately optimal ordering for join operators using a heuristic algorithm.Rule configuration.MultiJoinProjectTransposeRule implements the rule for pullingLogicalProject
s that are on top of aMultiJoin
and beneath aLogicalJoin
so theLogicalProject
appears above theLogicalJoin
.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Visitor for RelNodes which applies specifiedRexShuttle
visitor for every node in the tree.Visitor for RexNodes which replacesRexCorrelVariable
with specified.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Planner rule that converts SUM to SUM0 when it is the aggregate for an OVER clause inside the project list.Rule configuration.Planner rule that, given aProject
node that merely returns its input, converts the node into its child.Rule configuration.Rule configuration.Planner rule that converts aProject
on aTableScan
of aProjectableFilterableTable
to aBindables.BindableTableScan
.Rule configuration.Rule to convert aLogicalProject
to aLogicalCalc
.Rule configuration.Planner rule that slices aProject
into sections which contain windowed aggregate functions and sections which do not.Instance of the rule that applies to aCalc
that contains windowed aggregates and converts it into a mixture ofLogicalWindow
andCalc
.Rule configuration.Rule configuration.Instance of the rule that can be applied to aProject
and that produces, in turn, a mixture ofLogicalProject
andLogicalWindow
.Rule configuration.Planner rule that pushes aLogicalProject
past aLogicalWindow
.Rule configuration.Collection of rules which remove sections of a query plan known never to produce any rows.Configuration for rule that prunes a correlate if its left input is empty.Configuration for rule that prunes a correlate if its right input is empty.Configuration for a rule that prunes an Intersect if any of its inputs is empty.Configuration for rule that prunes a join it its left input is empty.Configuration for rule that prunes a join it its right input is empty.Configuration for a rule that prunes empty inputs from a Minus.Abstract prune empty rule that implements SubstitutionRule interface.Rule configuration.Rule that converts a relation into empty.Rule configuration.Configuration for a rule that prunes a Sort if it has limit 0.Configuration for a rule that prunes empty inputs from a Minus.Configuration for rule that transforms an empty relational expression into an empty values.PushProjector is a utility class used to perform operations used in push projection rules.A functor that replies true or false for a given expression.Rule that reduces decimal operations (such as casts or arithmetic) into operations involving more primitive types (such as longs and doubles).Rule configuration.A shuttle which converts decimal expressions to expressions based on longs.Rewrites a decimal expression for a specific set of SqlOperator's.Collection of planner rules that apply various simplifying transformations on RexNode trees.Rule that reduces constants inside aCalc
.Rule configuration.Shuttle that pushes predicates into a CASE.Rule configuration.Rule that reduces constants inside aFilter
.Rule configuration.Rule that reduces constants inside aJoin
.Rule configuration.Rule that reduces constants inside aProject
.Rule configuration.Helper class used to locate expressions that either can be reduced to literals or contain redundant casts.Replaces expressions with their reductions.Rule that reduces constants inside aWindow
.Rule configuration.Rule configuration.Planner rule that pushesSemiJoin
s down in a tree past aFilter
.Rule configuration.Rule configuration.Rule configuration.Planner rule that removes asemi-join
from a join tree.Rule configuration.Planner rule that creates aSemiJoin
from aJoin
on top of aLogicalAggregate
or on aRelNode
which is unique for join's right keys.Rule configuration.SemiJoinRule that matches a Project on top of a Join with a RelNode which is unique for Join's right keys.Rule configuration.SemiJoinRule that matches a Join with an empty Aggregate as its right input.Rule configuration.SemiJoinRule that matches a Project on top of a Join with an Aggregate as its right child.Rule configuration.Collection of rules which simplify joins which have one of their input as constant relationsValues
that produce a single row.Abstract class for all the SingleValuesOptimizationRules.Rule configuration.Rule configuration.Rule configuration.This rule try to merge the doubleSort
,one is Limit semantics, another sort is Limit or TOPN semantics.Rule configuration.Rule configuration.Planner rule that removes keys from a aSort
if those keys are known to be constant, or removes the entire Sort if all keys are constant.Rule configuration.Rule that removes redundantORDER BY
orLIMIT
when its input RelNode's maximum row count is less than or equal to specified row count.Rule configuration.Planner rule that removes aSort
if its input is already sorted.Rule configuration.Rule configuration.Collection of planner rules that convert calls to spatial functions into more efficient expressions.Rule that converts ST_DWithin in a Filter condition into a predicate on a Hilbert curve.Rule configuration.Transform that converts IN, EXISTS and scalar sub-queries into joins.Rule configuration.A rule that implements this interface indicates that the new RelNode is typically better than the old one.Deprecated.org.apache.calcite.rel.core.RelFactories.TableScanFactoryImpl
has calledRelOptTable.toRel(RelOptTable.ToRelContext)
.Rule configuration.Logical transformation rule, only logical operator can be rule operand, and only generate logical alternatives.UnionEliminatorRule
checks to see if its possible to optimize a Union call by eliminating the Union operator altogether in the case the call consists of only one input.Rule configuration.Rule configuration.Planner rule that pulls up constants through a Union operator.Rule configuration.Rule configuration.Rule configuration.Planner rule that folds projections and filters into an underlyingLogicalValues
.Rule configuration.
EquiJoin in 'core' package