The spec documents the direct output order of a SetRel as
The field order of the inputs. All inputs must have identical fields.
Having producers align the input types for set relations makes sense, however as written this also means they must align the nullability of the inputs, which is a bit more painful.
For example, the following inputs are aligned with regards to types, but not nullability.
The spec documents the direct output order of a SetRel as
Having producers align the input types for set relations makes sense, however as written this also means they must align the nullability of the inputs, which is a bit more painful.
For example, the following inputs are aligned with regards to types, but not nullability.
Proposal
We should loosen the input restriction to allow for inputs where all columns are the same type but with potentially differing nullbilities.
Along with this, we can provide the following derivation rules for output types:
UNION
If any of the input columns is null, the corresponding column of the output is null. A union of the inputs above would yield
INTERSECTION
If any of the input columns is not null, the corresponding column of the output is not null. An intersection of the inputs above would yield
MINUS
The output type is the type of the first input. A minus of the inputs above would yield