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

Generate nicer SQL for Sarg 'x IS NULL OR x NOT IN (1, 2)'

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.27.0
    • None
    • None

    Description

      When converting the Sarg

      x IS NULL OR x NOT IN (1, 2)

      to SQL, Calcite currently generates

      x IS NULL OR x < 1 OR x > 1 AND x < 2 OR x > 2

      This is correct SQL, but is difficult to read unless you know that AND has higher precedence than OR. Either of the following would be better:

      x IS NULL OR x <> 1 AND x <> 2
      x IS NULL OR x NOT IN (1, 2)

      Attachments

        Activity

          People

            julianhyde Julian Hyde
            julianhyde Julian Hyde
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: