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

ClassCastException in FilterReduceExpressionsRule

    Details

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

      Description

      L184 in ReduceExpressionsRule.

      ...
              if (newConditionExp instanceof RexCall) {
                RexCall rexCall = (RexCall) newConditionExp;
                boolean reverse = rexCall.getKind() == SqlKind.NOT;
                if (reverse) {
                  rexCall = (RexCall) rexCall.getOperands().get(0);
                }
                reduceNotNullableFilter(call, filter, rexCall, reverse);
              }
      ...
      

      When we take the NOT input, we do not consider that it might not be a RexCall, which may lead to the ClassCastException.

        Activity

        Hide
        jcamachorodriguez Jesus Camacho Rodriguez added a comment -

        Resolved in release 1.10.0 (2016-10-12).

        Show
        jcamachorodriguez Jesus Camacho Rodriguez added a comment - Resolved in release 1.10.0 (2016-10-12).
        Hide
        jcamachorodriguez Jesus Camacho Rodriguez added a comment -

        Your suggestion makes sense Julian Hyde, thanks!

        I have changed the code accordingly and added a new test that covers the issue.

        Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/0a1a190 .

        Show
        jcamachorodriguez Jesus Camacho Rodriguez added a comment - Your suggestion makes sense Julian Hyde , thanks! I have changed the code accordingly and added a new test that covers the issue. Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/0a1a190 .
        Hide
        julianhyde Julian Hyde added a comment -

        Need a test case.

        It might be simpler if reduceNotNullableFilter accepted any RexNode, not just RexCall; it would no-op if the arg was not IS_NULL, IS_UNKNOWN, IS_NOT_NULL. Then you can remove the casts and 'if' before you call it.

        Show
        julianhyde Julian Hyde added a comment - Need a test case. It might be simpler if reduceNotNullableFilter accepted any RexNode , not just RexCall ; it would no-op if the arg was not IS_NULL, IS_UNKNOWN, IS_NOT_NULL. Then you can remove the casts and 'if' before you call it.
        Hide
        jcamachorodriguez Jesus Camacho Rodriguez added a comment -
        Show
        jcamachorodriguez Jesus Camacho Rodriguez added a comment - Julian Hyde , could you take a look? https://github.com/apache/calcite/pull/287 Thanks

          People

          • Assignee:
            jcamachorodriguez Jesus Camacho Rodriguez
            Reporter:
            jcamachorodriguez Jesus Camacho Rodriguez
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development