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

FilterToProjectUnifyRule.invert(MutableRel, MutableRel, MutableProject) works incorrectly

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.6.0
    • Component/s: None
    • Labels:
      None

      Description

      The below code does not "invert" but only projects what's been projected. A type mismatch exception would be thrown when creating the new MutableProject.

            for (Ord<RexNode> expr : Ord.zip(project.getProjects())) {
              if (expr.e instanceof RexInputRef) {
                final int target = ((RexInputRef) expr.e).getIndex();
                exprList.set(expr.i,
                    rexBuilder.ensureType(expr.e.getType(),
                        RexInputRef.of(target, input.rowType),
                        false));
              } else {
                throw MatchFailed.INSTANCE;
              }
            }
      

      However, the exposure of this bug is quite low. Actually I couldn't find a query that would go through this code path, coz looks like any query that has a Filter will have a Project on top of that, which makes it go the other branch and use the other invert() method. A filtered view will produce a Filter on top of another Filter thus can reproduce this problem.

        Activity

        Hide
        maryannxue Maryann Xue added a comment -

        Julian Hyde Would you mind reviewing this patch?

        Show
        maryannxue Maryann Xue added a comment - Julian Hyde Would you mind reviewing this patch?
        Hide
        julianhyde Julian Hyde added a comment -

        +1

        I would be inclined to put the long string argument to withModel into a final String variable. I've noticed that IDEs are less likely to want to reformat such strings.

        Show
        julianhyde Julian Hyde added a comment - +1 I would be inclined to put the long string argument to withModel into a final String variable. I've noticed that IDEs are less likely to want to reformat such strings.
        Hide
        maryannxue Maryann Xue added a comment -
        Show
        maryannxue Maryann Xue added a comment - Thanks a lot, Julian Hyde , for the comments! Fixed in https://git1-us-west.apache.org/repos/asf/calcite/commit/f15566 .
        Hide
        julianhyde Julian Hyde added a comment -

        Resolved in release 1.6.0 (2016-01-22).

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

          People

          • Assignee:
            maryannxue Maryann Xue
            Reporter:
            maryannxue Maryann Xue
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development