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

SEARCHes in ANDs and ORs cannot be simplified if the complexity of its SARG can actually be reduced to 1

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • None
    • 1.27.0
    • core
    • None

    Description

      Consider the following test case in RexProgramTest.

      @Test void testSimplifySearch() {
        // (deptno <> 20 OR deptno IS NULL) AND deptno = 10
        //   ==>
        // deptno = 10
        final RexNode e =
          and(
            in(vInt(), literal(10), literal(20)),
            eq(vInt(), literal(10)));
        checkSimplify2(e, "=(?0.int0, 10)", "=(?0.int0, 10)");
      }
      

      We expect that AND(SEARCH(?0, [10, 20], =(?0, 10))) can be simplified to =(?0, 10) but fails. This is because RexSimplify#simplifyAnd and RexSimplify#simplifyOrs does not deal with the case when the complexity of SargCollector is 1.

      Attachments

        Issue Links

          Activity

            People

              danny0405 Danny Chen
              TsReaper Caizhi Weng
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: