Class ReplaceJoinOverConstantWithProject
- java.lang.Object
-
- io.trino.sql.planner.iterative.rule.ReplaceJoinOverConstantWithProject
-
public class ReplaceJoinOverConstantWithProject extends Object implements Rule<JoinNode>
This rule transforms plans with join where one of the sources is a single-row ValuesNode, and the join condition is `on true`. The JoinNode is replaced with the other join source and a projection which appends constant values from the ValuesNode. This rule is similar to ReplaceRedundantJoinWithSource.Note 1: When transforming an outer join (LEFT, RIGHT or FULL), and an outer source is a single row ValuesNode, it is checked that the other source is not empty. If it is possibly empty, the transformation cannot be done, because the result of the transformation would be possibly empty, while the single constant row should be preserved on output.
Note 2: The transformation is valid when the ValuesNode contains non-deterministic expressions. This is because any expression from the ValuesNode can only be used once. Assignments.Builder deduplicates them in case when the JoinNode produces any of the input symbols more than once.
Note 3: The transformation is valid when the ValuesNode contains expressions using correlation symbols. They are constant from the perspective of the transformed plan.
Transforms:
- join (on true), layout: (a, b, c) - source (a) - values b <- expr1 c <- expr2into:- project (a <- a, b <- expr1, c <- expr2) - source (a)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.trino.sql.planner.iterative.Rule
Rule.Context, Rule.Result
-
-
Constructor Summary
Constructors Constructor Description ReplaceJoinOverConstantWithProject()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Rule.Resultapply(JoinNode node, Captures captures, Rule.Context context)Pattern<JoinNode>getPattern()Returns a pattern to which plan nodes this rule applies.
-
-
-
Method Detail
-
getPattern
public Pattern<JoinNode> getPattern()
Description copied from interface:RuleReturns a pattern to which plan nodes this rule applies.- Specified by:
getPatternin interfaceRule<JoinNode>
-
apply
public Rule.Result apply(JoinNode node, Captures captures, Rule.Context context)
-
-