Class MergeProjectWithValues
java.lang.Object
io.trino.sql.planner.iterative.rule.MergeProjectWithValues
- All Implemented Interfaces:
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_2
into:
- 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), 1
Note: 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 -
Method Summary
Modifier and TypeMethodDescriptionapply(ProjectNode node, Captures captures, Rule.Context context) Returns a pattern to which plan nodes this rule applies.boolean
-
Constructor Details
-
MergeProjectWithValues
public MergeProjectWithValues()
-
-
Method Details
-
getPattern
Description copied from interface:RuleReturns a pattern to which plan nodes this rule applies.- Specified by:
getPatternin interfaceRule<ProjectNode>
-
isEnabled
- Specified by:
isEnabledin interfaceRule<ProjectNode>
-
apply
- Specified by:
applyin interfaceRule<ProjectNode>
-