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.
Related packages and classes
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 a
Aggregate.Rule configuration.Planner rule that rewrites an
WITHIN DISTINCTaggregate 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 an
Aggregate.Rule configuration.Rule configuration.Planner rule that reduces aggregate functions in
Aggregates to simpler forms.Rule configuration.Planner rule that removes a
Aggregateif it computes no aggregate functions (that is, it is implementing
SELECT DISTINCT), or all the aggregate functions are splittable, and the underlying relational expression is already distinct.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Type of relational expression.Planner rule that removes a trivial
LogicalCalc.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 convert
EXTRACT(timeUnit FROM dateTime) = constant,
FLOOR(dateTime to timeUnit= constant} and
CEIL(dateTime to timeUnit= constant} to
dateTime BETWEEN lower AND upper.Rule that converts EXTRACT, FLOOR and CEIL in a
Filterinto a date range.Rule configuration.Deprecated.Planner rule that removes keys from a
Exchangeif those keys are known to be constant.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Planner rule that matches a
Filterexpression with correlated variables, and rewrites the condition in a simpler form that is more convenient for the decorrelation logic.Rule configuration.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 two
LogicalFilters.Rule configuration.Rule configuration.Rule configuration.Planner rule that replaces
IS NOT DISTINCT FROMin a
Filterwith logically equivalent operations.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Rule configuration.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 a
Join.Rule configuration.Rule configuration.Rule configuration.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 configuration.Rule configuration.Rule configuration.Utility class used to store a
Jointree 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 a
MultiJoin.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 a
LogicalMatchto the result of calling
LogicalMatch.copy(org.apache.calcite.plan.RelTraitSet, java.util.List<org.apache.calcite.rel.RelNode>).Rule configuration.Rule configuration.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.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Visitor for RelNodes which applies specified
RexShuttlevisitor for every node in the tree.Visitor for RexNodes which replaces
RexCorrelVariablewith specified.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Planner rule that, given a
Projectnode that merely returns its input, converts the node into its child.Rule configuration.Rule configuration.Rule configuration.Rule configuration.Planner rule that slices a
Projectinto sections which contain windowed aggregate functions and sections which do not.Rule configuration.Rule configuration.Rule configuration.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 a
Calc.Rule configuration.Shuttle that pushes predicates into a CASE.Rule configuration.Rule that reduces constants inside a
Filter.Rule configuration.Rule that reduces constants inside a
Join.Rule configuration.Rule that reduces constants inside a
Project.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 a
Window.Rule configuration.Rule configuration.Planner rule that pushes
SemiJoins down in a tree past a
Filter.Rule configuration.Rule configuration.Rule configuration.Planner rule that removes a
semi-joinfrom a join tree.Rule configuration.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.Rule configuration.Rule configuration.This rule try to merge the double
Sort,one is Limit semantics, another sort is Limit or TOPN semantics.Rule configuration.Rule configuration.Planner rule that removes keys from a a
Sortif those keys are known to be constant, or removes the entire Sort if all keys are constant.Rule configuration.Rule that removes redundant
LIMITwhen its input RelNode's maximum row count is less than or equal to specified row count.Rule configuration.Planner rule that removes a
Sortif 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.
RelOptTable.toRel(RelOptTable.ToRelContext).Rule configuration.Logical transformation rule, only logical operator can be rule operand, and only generate logical alternatives.
UnionEliminatorRulechecks 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.Planner rule that folds projections and filters into an underlying