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.
-
Interface Summary Interface Description FilterJoinRule.Predicate Predicate that returns whether a filter is valid in the ON clause of a join for this particular kind of join.PushProjector.ExprCondition A functor that replies true or false for a given expression. -
Class Summary Class Description AbstractJoinExtractFilterRule AbstractMaterializedViewRule AbstractMaterializedViewRule.Edge Edge for graphAbstractMaterializedViewRule.EquivalenceClasses Class representing an equivalence class, i.e., a set of equivalent columnsAbstractMaterializedViewRule.MaterializedViewAggregateRule Materialized view rewriting for aggregateAbstractMaterializedViewRule.MaterializedViewJoinRule Materialized view rewriting for joinAbstractMaterializedViewRule.MaterializedViewOnlyAggregateRule Rule that matches Aggregate.AbstractMaterializedViewRule.MaterializedViewOnlyFilterRule Rule that matches Filter.AbstractMaterializedViewRule.MaterializedViewOnlyJoinRule Rule that matches Join.AbstractMaterializedViewRule.MaterializedViewProjectAggregateRule Rule that matches Project on Aggregate.AbstractMaterializedViewRule.MaterializedViewProjectFilterRule Rule that matches Project on Filter.AbstractMaterializedViewRule.MaterializedViewProjectJoinRule Rule that matches Project on Join.AbstractMaterializedViewRule.NodeLineage Expression lineage details.AbstractMaterializedViewRule.ViewPartialRewriting View partitioning resultAggregateExpandDistinctAggregatesRule Planner rule that expands distinct aggregates (such asCOUNT(DISTINCT x)
) from aAggregate
.AggregateExtractProjectRule AggregateFilterTransposeRule AggregateJoinTransposeRule AggregateJoinTransposeRule.Side Work space for an input to a join.AggregateProjectMergeRule AggregateProjectPullUpConstantsRule Planner rule that removes constant keys from anAggregate
.AggregateReduceFunctionsRule Planner rule that reduces aggregate functions inAggregate
s to simpler forms.AggregateRemoveRule Planner rule that removes aAggregate
if it computes no aggregate functions (that is, it is implementingSELECT DISTINCT
) and the underlying relational expression is already distinct.AggregateStarTableRule Planner rule that matches anAggregate
on top of aStarTable.StarTableScan
.AggregateUnionAggregateRule AggregateUnionTransposeRule AggregateValuesRule CalcMergeRule Planner rule that merges aLogicalCalc
onto aLogicalCalc
.CalcRelSplitter CalcRelSplitter.HighestUsageFinder Builds an array of the highest level which contains an expression which uses each expression as an input.CalcRelSplitter.ImplementTester Visitor which returns whether an expression can be implemented in a given type of relational expression.CalcRelSplitter.InputToCommonExprConverter Shuttle which converts every reference to an input field in an expression to a reference to a common sub-expression.CalcRelSplitter.MaxInputFinder Finds the highest level used by any of the inputs of a given expression.CalcRelSplitter.RelType Type of relational expression.CalcRemoveRule Planner rule that removes a trivialLogicalCalc
.CalcSplitRule CoerceInputsRule CoerceInputsRule pre-casts inputs to a particular type.DateRangeRules 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
.DateRangeRules.ExtractFinder Visitor that searches for calls toEXTRACT
,FLOOR
orCEIL
, building a list of distinct time units.DateRangeRules.ExtractShuttle Walks over an expression, replacing calls toEXTRACT
,FLOOR
andCEIL
with date ranges.DateRangeRules.FilterDateRangeRule Rule that converts EXTRACT, FLOOR and CEIL in aFilter
into a date range.EquiJoin Deprecated. FilterAggregateTransposeRule FilterCalcMergeRule Planner rule that merges aLogicalFilter
and aLogicalCalc
.FilterCorrelateRule FilterJoinRule Planner rule that pushes filters above and within a join node into the join node and/or its children nodes.FilterJoinRule.FilterIntoJoinRule Rule that tries to push filter expressions into a join condition and into the inputs of the join.FilterJoinRule.JoinConditionPushRule Rule that pushes parts of the join condition to its inputs.FilterMergeRule Planner rule that combines twoLogicalFilter
s.FilterMultiJoinMergeRule FilterProjectTransposeRule FilterRemoveIsNotDistinctFromRule Planner rule that replacesIS NOT DISTINCT FROM
in aFilter
with logically equivalent operations.FilterSetOpTransposeRule FilterTableFunctionTransposeRule Planner rule that pushes aLogicalFilter
past aLogicalTableFunctionScan
.FilterTableScanRule Planner rule that converts aFilter
on aTableScan
of aFilterableTable
or aProjectableFilterableTable
to aBindables.BindableTableScan
.FilterToCalcRule Planner rule that converts aLogicalFilter
to aLogicalCalc
.IntersectToDistinctRule JoinAddRedundantSemiJoinRule Rule to add a semi-join into a join.JoinAssociateRule Planner rule that changes a join based on the associativity rule.JoinCommuteRule Planner rule that permutes the inputs to aJoin
.JoinCommuteRule.VariableReplacer Walks over an expression, replacing references to fields of the left and right inputs.JoinExtractFilterRule JoinProjectTransposeRule Planner rule that matches aJoin
one of whose inputs is aLogicalProject
, and pulls the project up.JoinPushExpressionsRule Planner rule that pushes down expressions in "equal" join condition.JoinPushThroughJoinRule 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.JoinPushTransitivePredicatesRule JoinToCorrelateRule Rule that converts aLogicalJoin
into aLogicalCorrelate
, which can then be implemented using nested loops.JoinToMultiJoinRule Planner rule to flatten a tree ofLogicalJoin
s into a singleMultiJoin
with N inputs.JoinUnionTransposeRule LoptJoinTree Utility class used to store aJoin
tree and the factors that make up the tree.LoptJoinTree.BinaryTree 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.LoptJoinTree.Leaf Binary tree node that has no children.LoptJoinTree.Node Binary tree node that has two children.LoptMultiJoin Utility class that keeps track of the join factors that make up aMultiJoin
.LoptMultiJoin.Edge Information about a join-condition.LoptOptimizeJoinRule Planner rule that implements the heuristic planner for determining optimal join orderings.LoptSemiJoinOptimizer Implements the logic for determining the optimal semi-joins to be used in processing joins in a query.LoptSemiJoinOptimizer.FemLocalIndex Dummy class to allow code to compile.LoptSemiJoinOptimizer.LcsIndexOptimizer Dummy class to allow code to compile.LoptSemiJoinOptimizer.LcsTable Dummy class to allow code to compile.LoptSemiJoinOptimizer.LcsTableScan Dummy class to allow code to compile.LoptSemiJoinOptimizer.LucidDbSpecialOperators Dummy class to allow code to compile.MaterializedViewFilterScanRule MultiJoin A MultiJoin represents a join of N inputs, whereas regular Joins represent strictly binary joins.MultiJoinOptimizeBushyRule Planner rule that finds an approximately optimal ordering for join operators using a heuristic algorithm.MultiJoinOptimizeBushyRule.JoinVertex Participant in a join which is itself a join.MultiJoinOptimizeBushyRule.LeafVertex Relation participating in a join.MultiJoinOptimizeBushyRule.Vertex Participant in a join (relation or join).MultiJoinProjectTransposeRule MultiJoinProjectTransposeRule implements the rule for pullingLogicalProject
s that are on top of aMultiJoin
and beneath aLogicalJoin
so theLogicalProject
appears above theLogicalJoin
.ProjectCalcMergeRule Planner rule which merges aLogicalProject
and aLogicalCalc
.ProjectCorrelateTransposeRule Push Project under Correlate to apply on Correlate's left and right childProjectCorrelateTransposeRule.RelNodesExprsHandler Visitor for RelNodes which applies specifiedRexShuttle
visitor for every node in the tree.ProjectCorrelateTransposeRule.RexFieldAccessReplacer Visitor for RexNodes which replacesRexCorrelVariable
with specified.ProjectFilterTransposeRule ProjectJoinTransposeRule ProjectMergeRule ProjectMultiJoinMergeRule ProjectRemoveRule Planner rule that, given aProject
node that merely returns its input, converts the node into its child.ProjectSetOpTransposeRule Planner rule that pushes aLogicalProject
past aSetOp
.ProjectSortTransposeRule ProjectTableScanRule Planner rule that converts aProject
on aTableScan
of aProjectableFilterableTable
to aBindables.BindableTableScan
.ProjectToCalcRule Rule to convert aLogicalProject
to aLogicalCalc
ProjectToWindowRule Planner rule that slices aProject
into sections which contain windowed aggregate functions and sections which do not.ProjectToWindowRule.CalcToWindowRule Instance of the rule that applies to aCalc
that contains windowed aggregates and converts it into a mixture ofLogicalWindow
andCalc
.ProjectToWindowRule.ProjectToLogicalProjectAndWindowRule Instance of the rule that can be applied to aProject
and that produces, in turn, a mixture ofLogicalProject
andLogicalWindow
.ProjectToWindowRule.WindowedAggRelSplitter Splitter that distinguishes between windowed aggregation expressions (calls toRexOver
) and ordinary expressions.ProjectWindowTransposeRule Planner rule that pushes aLogicalProject
past aLogicalWindow
.PruneEmptyRules Collection of rules which remove sections of a query plan known never to produce any rows.PruneEmptyRules.RemoveEmptySingleRule Planner rule that converts a single-rel (e.g.PushProjector PushProjector is a utility class used to perform operations used in push projection rules.ReduceDecimalsRule ReduceDecimalsRule is a rule which reduces decimal operations (such as casts or arithmetic) into operations involving more primitive types (such as longs and doubles).ReduceExpressionsRule Collection of planner rules that apply various simplifying transformations on RexNode trees.ReduceExpressionsRule.CalcReduceExpressionsRule Rule that reduces constants inside aCalc
.ReduceExpressionsRule.CaseShuttle Shuttle that pushes predicates into a CASE.ReduceExpressionsRule.FilterReduceExpressionsRule Rule that reduces constants inside aFilter
.ReduceExpressionsRule.JoinReduceExpressionsRule Rule that reduces constants inside aJoin
.ReduceExpressionsRule.ProjectReduceExpressionsRule Rule that reduces constants inside aProject
.ReduceExpressionsRule.ReducibleExprLocator Helper class used to locate expressions that either can be reduced to literals or contain redundant casts.ReduceExpressionsRule.RexReplacer Replaces expressions with their reductions.SemiJoinFilterTransposeRule SemiJoinJoinTransposeRule SemiJoinProjectTransposeRule SemiJoinRemoveRule Planner rule that removes aSemiJoin
s from a join tree.SemiJoinRule SemiJoinRule.JoinToSemiJoinRule SemiJoinRule that matches a Join with an empty Aggregate as its right child.SemiJoinRule.ProjectToSemiJoinRule SemiJoinRule that matches a Project on top of a Join with an Aggregate as its right child.SortJoinTransposeRule SortProjectTransposeRule SortRemoveConstantKeysRule 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.SortRemoveRule Planner rule that removes aSort
if its input is already sorted.SortUnionTransposeRule SubQueryRemoveRule Transform that converts IN, EXISTS and scalar sub-queries into joins.SubQueryRemoveRule.ReplaceSubQueryShuttle Shuttle that replaces occurrences of a givenRexSubQuery
with a replacement expression.SubQueryRemoveRule.SubQueryFilterRemoveRule Rule that converts a sub-queries from filter expressions intoCorrelate
instances.SubQueryRemoveRule.SubQueryJoinRemoveRule Rule that converts sub-queries from join expressions intoCorrelate
instances.SubQueryRemoveRule.SubQueryProjectRemoveRule Rule that converts sub-queries from project expressions intoCorrelate
instances.TableScanRule Planner rule that converts aLogicalTableScan
to the result of callingRelOptTable.toRel(org.apache.calcite.plan.RelOptTable.ToRelContext)
.UnionEliminatorRule 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.UnionMergeRule UnionPullUpConstantsRule Planner rule that pulls up constants through a Union operator.UnionToDistinctRule ValuesReduceRule Planner rule that folds projections and filters into an underlyingLogicalValues
.ValuesReduceRule.MyRexShuttle Shuttle that converts inputs to literals. -
Enum Summary Enum Description AbstractMaterializedViewRule.MatchModality Complete, view partial, or query partial.ReduceExpressionsRule.ReducibleExprLocator.Constancy Whether an expression is constant, and if so, whether it can be reduced to a simpler constant. -
Exception Summary Exception Description CalcRelSplitter.CannotImplement Control exception forCalcRelSplitter.ImplementTester
.