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

Expressions with numeric comparisons are not simplified when CAST is present

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.29.0
    • 1.30.0
    • core

    Description

      For example:

      x = 1 and x <> 2

      In optimizer procedure, We pull up "x = 1" first, then when we encounter "x <> 2", can be simplified to "x = 1". So the result will be "x = 1"

      x <> 2 and x = 1

      When we pull up "x <> 2" first, it can't optimize the "x = 1".  So we need SARG to optimize it again.

      Because EQUALS and NOT-EQUALS operator will make the left RexNode become [CAST($t0): INTEGER NOT NULL] when the left node and right node have a least restrictive type.  So we need to handle the CAST operator.

      Attachments

        Issue Links

          Activity

            People

              nobigo xiong duan
              rusanu Remus Rusanu
              Votes:
              0 Vote for this issue
              Watchers:
              8 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 - 1h
                  1h