Class MergeProjectWithValues
- java.lang.Object
-
- io.trino.sql.planner.iterative.rule.MergeProjectWithValues
-
- All Implemented Interfaces:
Rule<ProjectNode>
public class MergeProjectWithValues extends Object implements Rule<ProjectNode>
Transforms:- Project a <- a d <- b e <- f(b) f <- 1 - Values(a, b, c) expr_a_1, expr_b_1, expr_c_1 expr_a_2, expr_b_2, expr_c_2into:- Values (a, d, e, f) expr_a_1, expr_b_1, f(expr_b_1), 1 expr_a_2, expr_b_2, f(expr_b_2), 1Note: this rule does not fire if ValuesNode contains a non-deterministic expression and it is referenced more than once in ProjectNode's assignments. This is to prevent incorrect results in the following case:- project row <- ROW(rand, rand) - Values(rand) rand()The expected result of the projection is a row with both fields equal. However, if the non-deterministic expression rand() was inlined, we would get two independent random values.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.trino.sql.planner.iterative.Rule
Rule.Context, Rule.Result
-
-
Constructor Summary
Constructors Constructor Description MergeProjectWithValues(Metadata metadata)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Rule.Resultapply(ProjectNode node, Captures captures, Rule.Context context)Pattern<ProjectNode>getPattern()Returns a pattern to which plan nodes this rule applies.booleanisEnabled(Session session)
-
-
-
Constructor Detail
-
MergeProjectWithValues
public MergeProjectWithValues(Metadata metadata)
-
-
Method Detail
-
getPattern
public Pattern<ProjectNode> getPattern()
Description copied from interface:RuleReturns a pattern to which plan nodes this rule applies.- Specified by:
getPatternin interfaceRule<ProjectNode>
-
isEnabled
public boolean isEnabled(Session session)
- Specified by:
isEnabledin interfaceRule<ProjectNode>
-
apply
public Rule.Result apply(ProjectNode node, Captures captures, Rule.Context context)
- Specified by:
applyin interfaceRule<ProjectNode>
-
-