[ https://issues.apache.org/jira/browse/CALCITE-3223?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Haisheng Yuan resolved CALCITE-3223. ------------------------------------ Fix Version/s: 1.21.0 Resolution: Fixed Fixed in https://github.com/apache/calcite/commit/729446005617059c0ce9fef4068087e4ca9ca139, thanks for the PR, [~jinxing6...@126.com]! > Non-RexInputRef may fails the matching of FilterToProjectUnifyRule during > 'invert' by mistake. > ---------------------------------------------------------------------------------------------- > > Key: CALCITE-3223 > URL: https://issues.apache.org/jira/browse/CALCITE-3223 > Project: Calcite > Issue Type: Bug > Components: core > Reporter: jin xing > Assignee: jin xing > Priority: Major > Labels: pull-request-available > Fix For: 1.21.0 > > Time Spent: 1h 10m > Remaining Estimate: 0h > > 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 items of {{exprList}} has already been set correctly. > As a result below tests fails. > {code:java} > @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); > } > {code} -- This message was sent by Atlassian Jira (v8.3.2#803003)