-
Type:
Improvement
-
Status: Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: Future
-
Component/s: Query Planning & Optimization
-
Labels:None
This test method and rule is not currently in the master branch, but it does appear in the patch posted for constant expression folding during planning, DRILL-2060. Once it is merged, the test TestConstantFolding.testConstExprFolding_InSelect() which is currently ignored, will be failing. The issue is that even though the constant folding rule for project is firing, and I have traced it to see that a replacement project with a literal is created, it is not being selected in the final plan. This seems rather odd, as there is a comment in the last line of the onMatch() method of the rule that says the following. This does not appear to be having the desired effect, may need to file a bug in calcite.
// New plan is absolutely better than old plan.
call.getPlanner().setImportance(project, 0.0);
Here is the query from the test, I expect the sum to be folded in planning with the newly enabled project constant folding rule.
select columns[0], 3+5 from cp.`test_input.csv`
There also some planning bugs that are exposed when this rule is enabled, even if the ReduceExpressionsRule.PROJECT_INSTANCE has no impact on the plan itself.
It is causing a planning bug for the TestAggregateFunctions.testDrill2092 as well as TestProjectPushDown.testProjectPastJoinPastFilterPastJoinPushDown(). The rule's OnMatch is being called, but not modifying the plan. It seems like its presence in the optimizer is making another rule fire that is creating a bad plan.