Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-1100

If ReduceExpressionsRule generates the same plan, the original plan stops triggering other rules

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.7.0
    • Component/s: core
    • Labels:
      None

      Description

      Calcite allows users to implement a customized RelOptPlanner#Executor to determine how a RexNode is reduced to another.

      In some cases, the customized RelOptPlanner#Executor might decide not to do any reduction for a given RexNode (i.e., constExps2 and reducedValues are the same in [1]).

      However, for these cases, Calcite is not aware of the new plan is equivalent to the old one, but just go ahead to force the Importance of the old/new plan as ZERO [2]. After the Importance becomes ZERO, the original plan stops triggering other rules

      [1] github code: https://github.com/apache/calcite/blob/f55d10c147746d6299fb713adc184576380a1f49/core/src/main/java/org/apache/calcite/rel/rules/ReduceExpressionsRule.java#L508

      [2] github code:
      https://github.com/apache/calcite/blob/f55d10c147746d6299fb713adc184576380a1f49/core/src/main/java/org/apache/calcite/rel/rules/ReduceExpressionsRule.java#L184

        Activity

        Hide
        seanhychu Sean Hsuan-Yi Chu added a comment -

        Julian Hyde Would you mind helping review ?

        https://github.com/apache/calcite/pull/199

        Thanks!

        Show
        seanhychu Sean Hsuan-Yi Chu added a comment - Julian Hyde Would you mind helping review ? https://github.com/apache/calcite/pull/199 Thanks!
        Hide
        julianhyde Julian Hyde added a comment -

        Reviewing now. Is there a test case? (We don't absolutely require one, but it would be nice.)

        Show
        julianhyde Julian Hyde added a comment - Reviewing now. Is there a test case? (We don't absolutely require one, but it would be nice.)
        Hide
        seanhychu Sean Hsuan-Yi Chu added a comment -

        Thanks for reviewing it.
        Actually, I observed this on DRILL's customized RelOptPlanner#Executor. (I have not seen it in Calcite's implementation of Executor).

        Show
        seanhychu Sean Hsuan-Yi Chu added a comment - Thanks for reviewing it. Actually, I observed this on DRILL's customized RelOptPlanner#Executor. (I have not seen it in Calcite's implementation of Executor).
        Hide
        julianhyde Julian Hyde added a comment -

        Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/eaa84951. Thanks for the PR, Sean Hsuan-Yi Chu!

        I agree we're OK without a test case. I refactored your code a bit, converting your 'for' loop with pair-wise comparisons into 'equals' on two lists of strings.

        Show
        julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/eaa84951 . Thanks for the PR, Sean Hsuan-Yi Chu ! I agree we're OK without a test case. I refactored your code a bit, converting your 'for' loop with pair-wise comparisons into 'equals' on two lists of strings.
        Hide
        julianhyde Julian Hyde added a comment -

        Resolved in release 1.7.0 (2016-03-22).

        Show
        julianhyde Julian Hyde added a comment - Resolved in release 1.7.0 (2016-03-22).

          People

          • Assignee:
            julianhyde Julian Hyde
            Reporter:
            seanhychu Sean Hsuan-Yi Chu
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development