You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit fa59434
Browse filesBrowse the repository at this point in the historyBrowse files
fix: do not prune ORDER BY keys using nullable UNIQUE constraints (apache#23918)
## Which issue does this PR close?
- Closesapache#23818.
## Rationale for this change
Please check the issue for details, but the main idea is that a nullable
`UNIQUE` column permits multiple NULL rows, so it does not determine
later sort keys across them and they must not be pruned.
## What changes are included in this PR?
- `FunctionalDependence` gets a `null_equality` field that records the
NULL semantics under which the dependency holds. The default is
`NullEqualsNothing`.
- Sort-key pruning only uses a dependency that holds when NULLs are
treated as equal (for example a GROUP BY key), has a non-nullable
determinant, or whose source columns are all `NOT NULL`.
- A primary key that is downgraded on the NULL-padded side of an outer
join keeps `NullEqualsNull`, because padded rows are NULL in every
column on that side.
- The dependency for the whole GROUP BY key is no longer skipped because
of a narrower dependency that doesn't hold across NULLs.
## Are these changes tested?
Yes. Regression tests are added in `functional_dependencies.slt` for
nullable `UNIQUE`, `NOT NULL UNIQUE`, LEFT JOIN with a primary key, and
GROUP BY over a nullable `UNIQUE` column.
## Are there any user-facing changes?
Yes: incorrect results are fixed. There is also an API change: the
public `FunctionalDependence` struct has a new `null_equality` field, so
code that builds it with a struct literal must switch to
`FunctionalDependence::new(..)`. This is documented in the 56.0.0
upgrade guide.
0 commit comments