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

UNNEST infers incorrect nullability for the result when applied to an array that contains nullable ROW values

    XMLWordPrintableJSON

Details

    Description

      An array can have nullable elements, which can be ROW values.
      Consider this example, validated in Postgres:

      CREATE TYPE person AS (
          id INTEGER,
          name TEXT
      );
      
      CREATE TABLE example_table (
          id SERIAL PRIMARY KEY,
          data person[]
      );
      
      SELECT (element).id AS name
      FROM example_table,
      UNNEST(data) AS element;
      

      If an element in the array is null, then the corresponding element.id is also null.
      However, Calcite infers a type of RecordType(BIGINT id) for the rows of this query, which is non-nullable.

      Attachments

        Activity

          People

            mbudiu Mihai Budiu
            mbudiu Mihai Budiu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: