As part of https://issues.apache.org/jira/browse/CALCITE-3975, I've
been looking into what ProjectFilterTransposeRule does with
expressions. It's one of our oldest rules, and I thought I knew what
it did. But the rule does not do what I expect. I've like to conduct a
straw poll to see what other people think.

Consider the following query (a Project on top of a Filter on a Scan).

  SELECT sal + comm AS remuneration
  FROM Emp
  WHERE deptno = 10

After applying ProjectFilterTransposeRule, what result would you
expect? What would the ideal result be? Are there any extreme cases
(large project lists, complex expressions, expensive filter
expressions) where the rule should do something different?

Please fill out the following:

  Expect: <option A, B or C, or a query>
  Hope: <option A, B or C, or a query>
  Comments:

Option A. Push down references to the fields needed by filter and
project expressions

  SELECT sal + comm AS remuneration
  FROM (
    SELECT sal, comm, deptno
    FROM Emp)
  WHERE deptno = 10

B. Push down the project expression, and references to the fields
needed by the filter

  SELECT remuneration
  FROM (
    SELECT sal + comm  AS remuneration, deptno
    FROM Emp)
  WHERE deptno = 10

C. Push down the project and filter expressions

 SELECT remuneration
  FROM (
    SELECT sal + comm  AS remuneration, deptno = 10 AS predicate
    FROM Emp)
  WHERE predicate

Julian

Reply via email to