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

Improve Nullability Derivation for Intersect and Minus

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • core

    Description

      SetOp overrides `deriveRowType()` and computes the output row type to be the least restrictive across all inputs here

      So for example given

      Input 1: (I64, I64, I64?, I64?)
      Input 2: (I64, I64?, I64, I64?) 

      where ? denotes nullable, the least restrictive output computes:

      Output:  (I64, I64?, I64?, I64?) 

      For UNION operations, these nullabilities are accurate.

      However for MINUS and INTERSECT there is room for improvement.

      MINUS only returns rows from the first input, as such its output nullability should always match that of its first input:

      Output: (I64, I64, I64?, I64?)  

      INTERSECT only returns rows that match across all inputs. If a column is not nullable in any of the inputs, then it is not nullable in the output because no rows can be emitted in which that column is null:

      Output: (I64, I64, I64, I64?)  

      Attachments

        Issue Links

          Activity

            People

              vbarua Victor Barua
              vbarua Victor Barua
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: