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

RexSimplify: eliminate redundant rex calls in OR

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.22.0
    • None

    Description

      Sample case to reproduce in

      RexProgramTest.simplifyOrTerms

      :

          // (a=1 or a=2 or (arr[1]>4 and arr[1]<3 and a=3)) => a=1 or a=2
          final RelDataType intArrayType = typeFactory.createArrayType(intType, -1);
          final RexInputRef ref0 = rexBuilder.makeInputRef(intType, 0);
          final RexInputRef ref3 = rexBuilder.makeInputRef(intArrayType, 3);
          final RexCall itm1 = (RexCall) rexBuilder.makeCall(intType, SqlStdOperatorTable.ITEM,
              ImmutableList.of(ref3, literal1));
          simplify = this.simplify.withParanoid(false);
          checkSimplifyFilter(
              or(
                  eq(ref0, literal1),
                  eq(ref0, literal2),
                  and(
                      gt(itm1, literal4),
                      lt(itm1, literal3),
                      eq(ref0, literal3)
                  )
              ),
              "OR(=($0, 1), =($0, 2))"
          );
          simplify = simplify.withParanoid(true);
      

      Attachments

        Issue Links

          Activity

            People

              ihuzenko Igor Guzenko
              ihuzenko Igor Guzenko
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 13h 40m
                  13h 40m