Package io.trino.sql.planner.iterative.rule
package io.trino.sql.planner.iterative.rule
-
ClassDescriptionFor task retry mode, dynamic filters are removed from the JoinNode/SemiJoinNode and rewritten into a DynamicFilterSourceNode below the remote exchange on the build side of the join.TransformsAdds INTERMEDIATE aggregations between an un-grouped FINAL aggregation and its preceding PARTIAL aggregation.This rule finds correlated UnnestNode in CorrelatedJoinNode's subquery and folds them into UnnestNode representing LEFT JOIN UNNEST.This rule finds correlated UnnestNode in CorrelatedJoinNode's subquery and folds them into UnnestNode representing LEFT JOIN UNNEST.This rule decorrelates plans with correlated UnnestNode and optional EnforceSingleRowNode, optional LimitNode, optional TopNNode and optional projections in the subquery.This rule must run after the distribution type has already been set for delete queries, since semi joins in delete queries must be replicated.Converts an Intersect node with at least one empty branch to an empty Values node.Replaces 0% sample node with empty values node.Transforms:Applies to broadcast spatial joins, inner and left, expressed via ST_Contains, ST_Intersects and ST_Distance functions.Transforms:Implement EXCEPT ALL using union, window and filter.Converts EXCEPT DISTINCT queries into UNION ALL..GROUP BY...WHERE E.g.:Implements filtered aggregations by transforming plans of the following shape:Implement INTERSECT ALL using union, window and filter.Converts INTERSECT DISTINCT queries into UNION ALL..GROUP BY...WHERE E.g.:Transforms:Transforms:This rule prepares cartesian product of partitions from all inputs of table function.Replace filter predicate conjuncts with underlying project expressions.Inlines expressions from a child project node into a parent project node as long as they are simple constants, or they are referenced only once (to avoid introducing duplicate computation) and the references don't appear within a TRY block (to avoid changing semantics).Transforms:Transforms:This rule handles both LimitNode with ties and LimitNode without ties.This rule handles both LimitNode with ties and LimitNode without ties.Transforms:Transforms:Implements distinct aggregations with different inputs by transforming plans of the following shape:For empty aggregations duplicate input rows can be skipped.Rule that transforms selected aggregations from:ProjectOffPushDownRule<N extends PlanNode>This rule restricts the outputs of ApplyNode's input and subquery based on which ApplyNode's output symbols are referenced.This rule updates ApplyNode's correlation list.This rule restricts outputs of ApplyNode's subquery to include only the symbols needed for subqueryAssignments.This rule restricts the outputs of CorrelatedJoinNode's input and subquery based on which CorrelatedJoinNode's output symbols are referenced.This rule updates CorrelatedJoinNode's correlation list.A count over a subquery can be reduced to a VALUES(1) provided the subquery is a scalarThis rule restricts the outputs of ExchangeNode based on which ExchangeNode's output symbols are either referenced by the parent node or used for partitioning, ordering or as a hash symbol by the ExchangeNode.This rule prunes GroupIdNode's aggregationArguments.Joins support output symbol selection, so make any project-off of child columns explicit in project nodes.Joins support output symbol selection, so absorb any project-off into the node.This rule restricts the inputs to PatternRecognitionNode based on which symbols are used by the inner structures of the PatternRecognitionNode.Spatial joins support output symbol selection, so absorb any project-off into the node.TableFunctionProcessorNode has two kinds of outputs: - proper outputs, which are the columns produced by the table function, - pass-through outputs, which are the columns copied from table arguments.This rule prunes unreferenced outputs of TableFunctionProcessorNode.This is a special case of PushProjectionIntoTableScan that performs only column pruning.TransformsAbsorb pruning projection into the node.This optimizer pushes aggregations below outer joins when: the aggregation is on top of the outer join, it groups by all columns in the outer table, and the outer rows are guaranteed to be distinct.Transforms expressions of the formTransforms:Transforms:Transforms:Transforms:Transforms:Transforms:Transforms:Transforms:Transforms:Transforms:Transforms:Transforms:Transforms:Aggregate functions in pattern recognition context have special semantics.Push down aggregation's mask based on filter predicate.Rule that transform plan likeTransforms:Transforms:Transforms:This version support only constant updates and fall back to default behaviour in all other casesTransforms:These rules should not be run after AddExchanges so as not to overwrite the TableLayout chosen by AddExchangesThis rule pushes filter predicate concerning row number symbol into RowNumberNode by modifying maxRowCountPerPartition.This rule pushes filter predicate concerning a ranking symbol into WindowNode by converting it into TopNRankingNode.Transforms:Utility class for pushing projections through inner join so that joins are not separated by a project node and can participate in cross join elimination or join reordering.Pushes RemoteExchange node down through the AssignUniqueId to preserve partitioned_on(unique) and grouped(unique) properties for the output of the AssignUniqueId.Transforms:Transforms:Remove the aggregation node that produces distinct rows from the Filtering source of a Semi join.Flattens and removes duplicate conjuncts or disjuncts.Removes branches from an ExceptNode that are guaranteed to produce 0 rows.If the predicate for a mergeWriter is optimized to false, the target table scan of the mergeWriter will be replaced with an empty values node.If the predicate for a table execute is optimized to false, the target table scan of table execute will be replaced with an empty values node.Removes branches from a UnionNode that are guaranteed to produce 0 rows.Removes 100% sample nodes.Replace DistinctLimit node 1.Given:Removes projection nodes that only perform non-renaming identity projectionsRemove Limit node when the subplan is guaranteed to produce fewer rows than the limit and replace the plan with empty values if the limit count is 0.Remove Offset node and its subplan when the subplan is guaranteed to produce no more rows than the offset and replace the plan with empty values.This rule removes SortNode being a source of LimitNode with ties.Table function can take multiple table arguments.Replace TopN node 1.Dynamic filters are supported only right after TableScan and only if the subtree is on 1.This rule transforms plans with join where one of the sources is a single-row ValuesNode, and the join condition is `on true`.This rule is complementary to RemoveRedundantJoin.This rule transforms plans with joins, where: - one of the sources is scalar and produces no output symbols.Re-writes spatial_partitioning(geometry) aggregations into spatial_partitioning(envelope, partition_count) on top of ST_Envelope(geometry) projection, e.g.Simplify conditional expressions in filter predicate.Implements distinct aggregations with similar inputs by transforming plans of the following shape:This rule decorrelates a correlated subquery of LEFT correlated join with distinct operator (grouped aggregation with no aggregation assignments) It is similar to TransformCorrelatedDistinctAggregationWithProjection rule, but does not support projection over aggregation in the subqueryThis rule decorrelates a correlated subquery of LEFT correlated join with distinct operator (grouped aggregation with no aggregation assignments)This rule decorrelates a correlated subquery with: - single global aggregation, or - global aggregation over distinct operator (grouped aggregation with no aggregation assignments), in case when the distinct operator cannot be de-correlated by PlanNodeDecorrelator It is similar to TransformCorrelatedGlobalAggregationWithProjection rule, but does not support projection over aggregation in the subqueryThis rule decorrelates a correlated subquery of LEFT or INNER correlated join with: - single global aggregation, or - global aggregation over distinct operator (grouped aggregation with no aggregation assignments), in case when the distinct operator cannot be de-correlated by PlanNodeDecorrelatorThis rule decorrelates a correlated subquery of INNER correlated join with: - single grouped aggregation, or - grouped aggregation over distinct operator (grouped aggregation with no aggregation assignments), in case when the distinct operator cannot be de-correlated by PlanNodeDecorrelator It is similar to TransformCorrelatedGroupedAggregationWithProjection rule, but does not support projection over aggregation in the subqueryThis rule decorrelates a correlated subquery of INNER correlated join with: - single grouped aggregation, or - grouped aggregation over distinct operator (grouped aggregation with no aggregation assignments), in case when the distinct operator cannot be de-correlated by PlanNodeDecorrelatorReplaces correlated ApplyNode with InPredicate expression with SemiJoinTries to decorrelate subquery and rewrite it using normal join.Scalar filter scan query is something like:This optimizer can rewrite correlated single row subquery to projection in a way described here: From:EXISTS is modeled as (if correlated predicates are equality comparisons):Rewrite filtering semi-join to inner join.This optimizers looks for InPredicate expressions in ApplyNodes and replaces the nodes with SemiJoin nodes.Given s of type S, a constant expression t of type T, and when an implicit cast exists between S->T, converts expression of the form:Given constant temporal unit U and a constant date/time expression t that's rounded to unit, converts expression of the formTransforms expressions of the form
ROW(x, y)[1]toxandCAST(ROW(x, y) AS row(f1 type1, f2 type2))[1]toCAST(x AS type1)Given x::row(t) and y::row(t), converts assignments of the formTransforms a constant date/time expression tRule that transforms