You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Stamatis Zampetakis (Jira)" <ji...@apache.org> on 2022/04/11 09:15:00 UTC
[jira] [Commented] (CALCITE-4936) Generalize FilterCalcMergeRule/ProjectCalcMergeRule to accept any Filter/Project/Calc operator
[ https://issues.apache.org/jira/browse/CALCITE-4936?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17520454#comment-17520454 ]
Stamatis Zampetakis commented on CALCITE-4936:
----------------------------------------------
After this change there is slight (breaking) change in the behavior of the {{ProjectCalcMergeRule}} when the top project contains a window function.
+Old behavior:+
The {{Project}} operator is transformed into {{Calc}}.
+New behavior:+
The {{Project}} operator is not transformed and the rule becomes NOOP.
For most users the change will pass unnoticed since the {{ProjectToCalcRule}} will be used to complete the transformation.
> Generalize FilterCalcMergeRule/ProjectCalcMergeRule to accept any Filter/Project/Calc operator
> ----------------------------------------------------------------------------------------------
>
> Key: CALCITE-4936
> URL: https://issues.apache.org/jira/browse/CALCITE-4936
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Affects Versions: 1.28.0
> Reporter: Maksim Gramin
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.31.0
>
> Time Spent: 1h 10m
> Remaining Estimate: 0h
>
> I noticed that rules ProjectCalcMergeRule and FilterCalcMergeRule strictly dependent on LogicalCalc class (e.g. casting call.rel to LogicalCalc, using LogicalCalc.create method and etc). I suggest making them more generalized (like CalcMergeRule) and use only Project, Filter and Calc interfaces, which will expand the range of their applying.
> Concrete:
> 1. In FilterCalcMergeRule get rid of casting to LogicalCalc and LogicalFilter:
> {code:java}
> @Override public void onMatch(RelOptRuleCall call) {
> final Filter filter = call.rel(0);
> final Calc calc = call.rel(1);{code}
>
> 2. In FilterCalcMergeRule and FilterCalcMergeRule replace LogicalCalc.create with calc.copy:
> {code:java}
> final Calc newCalc = calc.copy(calc.getTraitSet(), calc.getInput(),
> mergedProgram);{code}
>
> 3. In ProjectCalcMergeRule replace the code:
> {code:java}
> if (RexOver.containsOver(program)) {
> LogicalCalc projectAsCalc = LogicalCalc.create(calc, program);
> call.transformTo(projectAsCalc);
> return;
> }{code}
> with a simple one:
> {code:java}
> if (RexOver.containsOver(program)) {
> return;
> }{code}
> because special rule ProjectToCalcRule convert LogicalProject to LogicalCalc.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)