jinxing64 opened a new pull request #1346: [CALCITE-3223] Non-RexInputRef may 
fails the matching of FilterToProjectUnifyRule during 'invert' by mistake
URL: https://github.com/apache/calcite/pull/1346
 
 
   In current code of 
FilterToProjectUnifyRule::invert(https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java#L1124),
 the implementation 
   1. Fails the matching when there is Non-RexInputRef in the projects
   2. Didn't check if all `exprList` has already ben set correctly.
   As a result below tests fails.
   ```
     @Test public void testFilterToProject0() {
       String union =
           "select * from \"emps\" where \"empid\" > 300\n"
               + "union all select * from \"emps\" where \"empid\" < 200";
       String mv = "select *, \"empid\" * 2 from (" + union + ")";
       String query = "select * from (" + union + ") where (\"empid\" * 2) > 3";
       checkMaterialize(mv, query);
     }
   
     @Test public void testFilterToProject1() {
       String agg =
           "select \"deptno\", count(*) as \"c\", sum(\"salary\") as \"s\"\n"
               + "from \"emps\" group by \"deptno\"";
       String mv = "select \"c\", \"s\", \"s\" from (" + agg + ")";
       String query = "select * from (" + agg + ") where (\"s\" * 0.8) > 10000";
       checkNoMaterialize(mv, query, HR_FKUK_MODEL);
     }
   ```
   This PR proposes to refine the method of `invert`:
   1. `Projects` is regarded as valid as long as all the input fields are 
projected
   2.  Check if all `exprList` has already ben set correctly.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to