Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-5065

Inconsistent treatment of NULL and empty string

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 4.14.1
    • 5.1.0, 4.16.0
    • None
    • None

    Description

      Phoenix doesn't handle NULLs consistently with other SQL dialects, and it doesn't handle them consistently internally either.

      In PHOENIX-2422, jamestaylor mentioned that Phoenix's intended behavior is for empty string and NULL to be equivalent. That's inconsistent with other SQL dialects (in which NULL is never equal to anything, including itself), but if that's our documented behavior, then that's fine unless PHOENIX-2422 to change it is ever worked.

      But consider the following queries:

      SELECT COUNT(*) FROM SYSTEM.CATALOG WHERE TENANT_ID = '';
      -- Returns 0 rows
      SELECT COUNT(*) FROM SYSTEM.CATALOG WHERE TENANT_ID IS NULL;
      -- Returns some number of rows. Call it N
      SELECT COUNT(*) FROM SYSTEM.CATALOG WHERE TENANT_ID IN ('');
      -- Returns 0 rows
      SELECT COUNT(*) FROM SYSTEM.CATALOG WHERE TENANT_ID IN ('', 'FOO');
      -- Returns N rows. Note that FOO does not exist, and is just a nonsense string
      SELECT COUNT(*) FROM SYSTEM.CATALOG WHERE TENANT_ID = '' OR TENANT_ID = 'FOO'
      --Returns 0 rows, but slowly
      

      Attachments

        1. PHOENIX-5065.master.v5.patch
          8 kB
          Richárd Antal
        2. PHOENIX-5065.master.v4.patch
          8 kB
          Richárd Antal
        3. PHOENIX-5065.master.v3.patch
          3 kB
          Richárd Antal
        4. PHOENIX-5065.master.v2.patch
          3 kB
          Richárd Antal
        5. PHOENIX-5065.master.v1.patch
          3 kB
          Richárd Antal

        Activity

          People

            richardantal Richárd Antal
            gjacoby Geoffrey Jacoby
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: