Class 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_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.