-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix NULL handling in ScalarValue::partial_cmp (closes #19579) #19587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Brijesh-Thakkar
wants to merge
10
commits into
apache:main
Choose a base branch
from
Brijesh-Thakkar:fix-scalarvalue-null-partial-cmp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+89
−21
Open
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4fb4147
Fix ScalarValue partial ordering behavior with NULLs
Brijesh-Thakkar 390c7c7
Remove unreachable NULL match arm in ScalarValue::partial_cmp
Brijesh-Thakkar 500697e
Add tests for explicit ScalarValue::Null partial ordering
Brijesh-Thakkar d868e5b
docs: clarify try_cmp behavior for NULL inputs
Brijesh-Thakkar 1e8b532
Align vector ordering with PostgreSQL NULL semantics
Brijesh-Thakkar b79699a
Merge branch 'main' into fix-scalarvalue-null-partial-cmp
Brijesh-Thakkar 552a1e9
Align vector ordering tests with ScalarValue NULL partial_cmp semantics
Brijesh-Thakkar 6ef8e57
Merge branch 'main' into fix-scalarvalue-null-partial-cmp
Brijesh-Thakkar 8cdb969
Fix ScalarValue partial_cmp and clippy warnings in datafusion-common
Brijesh-Thakkar 3f8c1db
Fix ORDER BY rewrite for aggregate aliases and preserve casts
Brijesh-Thakkar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we do something like
to be more defensive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After investigating this further, I aligned the behavior with existing ScalarValue::partial_cmp semantics:
ScalarValue::partial_cmp continues to return None for any NULL comparison (including NULL vs NULL), consistent with SQL tri-state logic and existing DataFusion tests.
The failure in vector_ord was due to an incorrect test expectation assuming vectors containing NULLs were orderable.
I’ve updated the test to explicitly assert that vector comparison returns None when NULLs are encountered, rather than expecting < to succeed.
Implementing PostgreSQL-style composite ordering (NULL == NULL inside arrays/structs) would require a separate, higher-level comparison strategy and a conscious semantic change. I’ve kept this PR scoped to fixing the inconsistency without altering scalar comparison behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense to implement this pg-compatible array comparison in a separate PR, I'll file a ticket afterwards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for confirming
Agreed on keeping PostgreSQL-style composite ordering as a separate follow-up PR.
I’ll keep an eye on CI and update if anything comes up.