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

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.27.0
    • Component/s: None
    • Labels:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: