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

'xx < 1 OR xx > 1' cannot be simplified to 'xx <> 1'

    XMLWordPrintableJSON

Details

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

    Description

      As described in the title, xx < 1 OR xx > 1 should be simplified to xx <> 1.

      See discussion in ML: https://lists.apache.org/thread/hsdgx0jb3214v6k9p7slbkk3xsbl0b7f
      The original problem is that ename <> '' and ename <> '3' could be simplified to Sarg while (ename < '' or ename > '') and (ename < '3' or ename > '3') cannot.
      Since < and <> have different SqlOperandTypeChecker.Consistency, the type inference result is different for these two cases. We suspect that the type inference result leads to the difference of simplification.
      However, the real reason is that xx < 1 OR xx > 1 cannot be simplified to xx <> 1 in simplification, which prevents (ename < '' or ename > '') and (ename < '3' or ename > '3') being simplified to ename <> '' and ename <> '3'.

      Attachments

        Issue Links

          Activity

            People

              libenchao Benchao Li
              libenchao Benchao Li
              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 - 1h 10m
                  1h 10m