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
Interface Summary Interface Description FilterJoinRule.PredicatePredicate that returns whether a filter is valid in the ON clause of a join for this particular kind of join. PushProjector.ExprConditionA functor that replies true or false for a given expression.
Class Summary Class Description AbstractJoinExtractFilterRule AbstractMaterializedViewRule AbstractMaterializedViewRule.EdgeEdge for graph AbstractMaterializedViewRule.EquivalenceClassesClass representing an equivalence class, i.e., a set of equivalent columns AbstractMaterializedViewRule.MaterializedViewAggregateRuleMaterialized view rewriting for aggregate AbstractMaterializedViewRule.MaterializedViewJoinRuleMaterialized view rewriting for join AbstractMaterializedViewRule.MaterializedViewOnlyAggregateRuleRule that matches Aggregate. AbstractMaterializedViewRule.MaterializedViewOnlyFilterRuleRule that matches Filter. AbstractMaterializedViewRule.MaterializedViewOnlyJoinRuleRule that matches Join. AbstractMaterializedViewRule.MaterializedViewProjectAggregateRuleRule that matches Project on Aggregate. AbstractMaterializedViewRule.MaterializedViewProjectFilterRuleRule that matches Project on Filter. AbstractMaterializedViewRule.MaterializedViewProjectJoinRuleRule that matches Project on Join. AbstractMaterializedViewRule.NodeLineageExpression lineage details. AbstractMaterializedViewRule.ViewPartialRewritingView partitioning result AggregateExpandDistinctAggregatesRulePlanner rule that expands distinct aggregates (such as
COUNT(DISTINCT x)) from a
AggregateExtractProjectRule AggregateFilterTransposeRule AggregateJoinJoinRemoveRule AggregateJoinRemoveRule AggregateJoinTransposeRule AggregateJoinTransposeRule.SideWork space for an input to a join. AggregateMergeRule AggregateProjectMergeRule AggregateProjectPullUpConstantsRulePlanner rule that removes constant keys from an
AggregateReduceFunctionsRulePlanner rule that reduces aggregate functions in
Aggregates to simpler forms.
AggregateRemoveRulePlanner 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.
AggregateStarTableRule AggregateUnionAggregateRule AggregateUnionTransposeRule AggregateValuesRule CalcMergeRule CalcRelSplitter CalcRelSplitter.HighestUsageFinderBuilds an array of the highest level which contains an expression which uses each expression as an input. CalcRelSplitter.ImplementTesterVisitor which returns whether an expression can be implemented in a given type of relational expression. CalcRelSplitter.InputToCommonExprConverterShuttle which converts every reference to an input field in an expression to a reference to a common sub-expression. CalcRelSplitter.MaxInputFinderFinds the highest level used by any of the inputs of a given expression. CalcRelSplitter.RelTypeType of relational expression. CalcRemoveRulePlanner rule that removes a trivial
CalcSplitRule CoerceInputsRuleCoerceInputsRule pre-casts inputs to a particular type. DateRangeRulesCollection 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.
DateRangeRules.ExtractFinderVisitor that searches for calls to
CEIL, building a list of distinct time units.
DateRangeRules.ExtractShuttleWalks over an expression, replacing calls to
CEILwith date ranges.
DateRangeRules.FilterDateRangeRuleRule that converts EXTRACT, FLOOR and CEIL in a
Filterinto a date range.
EquiJoin Deprecated. ExchangeRemoveConstantKeysRulePlanner rule that removes keys from a
Exchangeif those keys are known to be constant.
ExchangeRemoveConstantKeysRule.SortExchangeRemoveConstantKeysRuleRule that reduces constants inside a
FilterAggregateTransposeRule FilterCalcMergeRule FilterCorrelateRule FilterJoinRulePlanner rule that pushes filters above and within a join node into the join node and/or its children nodes. FilterJoinRule.FilterIntoJoinRuleRule that tries to push filter expressions into a join condition and into the inputs of the join. FilterJoinRule.JoinConditionPushRuleRule that pushes parts of the join condition to its inputs. FilterMergeRulePlanner rule that combines two
FilterMultiJoinMergeRule FilterProjectTransposeRule FilterRemoveIsNotDistinctFromRulePlanner rule that replaces
IS NOT DISTINCT FROMin a
Filterwith logically equivalent operations.
FilterSetOpTransposeRule FilterTableFunctionTransposeRule FilterTableScanRule FilterToCalcRule IntersectToDistinctRule JoinAddRedundantSemiJoinRuleRule to add a semi-join into a join. JoinAssociateRulePlanner rule that changes a join based on the associativity rule. JoinCommuteRulePlanner rule that permutes the inputs to a
JoinCommuteRule.VariableReplacerWalks over an expression, replacing references to fields of the left and right inputs. JoinExtractFilterRule JoinProjectTransposeRule JoinPushExpressionsRulePlanner rule that pushes down expressions in "equal" join condition. JoinPushThroughJoinRuleRule 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 JoinToMultiJoinRule JoinUnionTransposeRule LoptJoinTreeUtility class used to store a
Jointree and the factors that make up the tree.
LoptJoinTree.BinaryTreeSimple 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.LeafBinary tree node that has no children. LoptJoinTree.NodeBinary tree node that has two children. LoptMultiJoinUtility class that keeps track of the join factors that make up a
LoptMultiJoin.EdgeInformation about a join-condition. LoptOptimizeJoinRulePlanner rule that implements the heuristic planner for determining optimal join orderings. LoptSemiJoinOptimizerImplements the logic for determining the optimal semi-joins to be used in processing joins in a query. LoptSemiJoinOptimizer.FemLocalIndexDummy class to allow code to compile. LoptSemiJoinOptimizer.LcsIndexOptimizerDummy class to allow code to compile. LoptSemiJoinOptimizer.LcsTableDummy class to allow code to compile. LoptSemiJoinOptimizer.LcsTableScanDummy class to allow code to compile. LoptSemiJoinOptimizer.LucidDbSpecialOperatorsDummy class to allow code to compile. MaterializedViewFilterScanRule MultiJoinA MultiJoin represents a join of N inputs, whereas regular Joins represent strictly binary joins. MultiJoinOptimizeBushyRulePlanner rule that finds an approximately optimal ordering for join operators using a heuristic algorithm. MultiJoinOptimizeBushyRule.JoinVertexParticipant in a join which is itself a join. MultiJoinOptimizeBushyRule.LeafVertexRelation participating in a join. MultiJoinOptimizeBushyRule.VertexParticipant in a join (relation or join). MultiJoinProjectTransposeRule ProjectCalcMergeRule ProjectCorrelateTransposeRulePush Project under Correlate to apply on Correlate's left and right child ProjectCorrelateTransposeRule.RelNodesExprsHandlerVisitor for RelNodes which applies specified
RexShuttlevisitor for every node in the tree.
ProjectCorrelateTransposeRule.RexFieldAccessReplacerVisitor for RexNodes which replaces
ProjectFilterTransposeRule ProjectJoinJoinRemoveRule ProjectJoinRemoveRule ProjectJoinTransposeRule ProjectMergeRule ProjectMultiJoinMergeRule ProjectRemoveRulePlanner rule that, given a
Projectnode that merely returns its input, converts the node into its child.
ProjectSetOpTransposeRule ProjectSortTransposeRule ProjectTableScanRule ProjectToCalcRule ProjectToWindowRulePlanner rule that slices a
Projectinto sections which contain windowed aggregate functions and sections which do not.
ProjectToWindowRule.CalcToWindowRule ProjectToWindowRule.ProjectToLogicalProjectAndWindowRule ProjectToWindowRule.WindowedAggRelSplitterSplitter that distinguishes between windowed aggregation expressions (calls to
RexOver) and ordinary expressions.
ProjectWindowTransposeRule PruneEmptyRulesCollection of rules which remove sections of a query plan known never to produce any rows. PruneEmptyRules.RemoveEmptySingleRulePlanner rule that converts a single-rel (e.g. PushProjectorPushProjector is a utility class used to perform operations used in push projection rules. ReduceDecimalsRuleReduceDecimalsRule is a rule which reduces decimal operations (such as casts or arithmetic) into operations involving more primitive types (such as longs and doubles). ReduceExpressionsRuleCollection of planner rules that apply various simplifying transformations on RexNode trees. ReduceExpressionsRule.CalcReduceExpressionsRuleRule that reduces constants inside a
ReduceExpressionsRule.CaseShuttleShuttle that pushes predicates into a CASE. ReduceExpressionsRule.FilterReduceExpressionsRuleRule that reduces constants inside a
ReduceExpressionsRule.JoinReduceExpressionsRuleRule that reduces constants inside a
ReduceExpressionsRule.ProjectReduceExpressionsRuleRule that reduces constants inside a
ReduceExpressionsRule.ReducibleExprLocatorHelper class used to locate expressions that either can be reduced to literals or contain redundant casts. ReduceExpressionsRule.RexReplacerReplaces expressions with their reductions. ReduceExpressionsRule.WindowReduceExpressionsRuleRule that reduces constants inside a
SemiJoinFilterTransposeRulePlanner rule that pushes
SemiJoins down in a tree past a
SemiJoinJoinTransposeRulePlanner rule that pushes a
SemiJoindown in a tree past a
Joinin order to trigger other rules that will convert
SemiJoinProjectTransposeRulePlanner rule that pushes a
SemiJoindown in a tree past a
SemiJoinRemoveRulePlanner rule that removes a
SemiJoins from a join tree.
SemiJoinRule SemiJoinRule.JoinToSemiJoinRuleSemiJoinRule that matches a Join with an empty Aggregate as its right child. SemiJoinRule.ProjectToSemiJoinRuleSemiJoinRule that matches a Project on top of a Join with an Aggregate as its right child. SortJoinTransposeRule SortProjectTransposeRule SortRemoveConstantKeysRulePlanner 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.
SortRemoveRulePlanner rule that removes a
Sortif its input is already sorted.
SortUnionTransposeRule SubQueryRemoveRuleTransform that converts IN, EXISTS and scalar sub-queries into joins. SubQueryRemoveRule.ReplaceSubQueryShuttleShuttle that replaces occurrences of a given
RexSubQuerywith a replacement expression.
SubQueryRemoveRule.SubQueryFilterRemoveRuleRule that converts a sub-queries from filter expressions into
SubQueryRemoveRule.SubQueryJoinRemoveRuleRule that converts sub-queries from join expressions into
SubQueryRemoveRule.SubQueryProjectRemoveRuleRule that converts sub-queries from project expressions into
TableScanRulePlanner rule that converts a
LogicalTableScanto the result of calling
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.
UnionMergeRule UnionPullUpConstantsRulePlanner rule that pulls up constants through a Union operator. UnionToDistinctRule ValuesReduceRulePlanner rule that folds projections and filters into an underlying
ValuesReduceRule.MyRexShuttleShuttle that converts inputs to literals.
Enum Summary Enum Description AbstractMaterializedViewRule.MatchModalityComplete, view partial, or query partial. ReduceExpressionsRule.ReducibleExprLocator.ConstancyWhether an expression is constant, and if so, whether it can be reduced to a simpler constant.
Exception Summary Exception Description CalcRelSplitter.CannotImplementControl exception for