Skip to content

fix: GROUP BY returns two rows for the NULL group with a nullable UNIQUE constraint - #24103

Open
LDM-A wants to merge 3 commits into
apache:mainfrom
LDM-A:ldm/datafusion-23820
Open

fix: GROUP BY returns two rows for the NULL group with a nullable UNIQUE constraint#24103
LDM-A wants to merge 3 commits into
apache:mainfrom
LDM-A:ldm/datafusion-23820

Conversation

@LDM-A

@LDM-A LDM-A commented Aug 5, 2026

Copy link
Copy Markdown

Which issue does this PR close?

Rationale for this change

Explained accordingly in the issue linked above.

What changes are included in this PR?

  1. Introduces a "duplicate_nulls" field to "FunctionalDependence" to distinguish UNIQUE constraints from PRIMARY_KEY constraints.
  2. Skips UNIQUE dependencies in "get_target_functional_dependencies" so dependent columns are no longer added to GROUP_BY
  3. Adds "get_nullable_unique_target_functional_dependencies" to identify targets of UNIQUE dependencies.

Are these changes tested?

Yes exisiting tests created by @alamb previously.

Are there any user-facing changes?

No public API changes

@github-actions github-actions Bot added sql SQL Planner common Related to common crate labels Aug 5, 2026
@LDM-A
LDM-A marked this pull request as draft August 5, 2026 11:35
@LDM-A
LDM-A marked this pull request as ready for review August 5, 2026 11:42
@LDM-A
LDM-A marked this pull request as draft August 5, 2026 11:50
@github-actions github-actions Bot added the sqllogictest SQL Logic Tests (.slt) label Aug 5, 2026
@LDM-A
LDM-A marked this pull request as ready for review August 5, 2026 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to common crate sql SQL Planner sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect results: GROUP BY returns two rows for the NULL group with a nullable UNIQUE constraint

1 participant