Skip to content

fix: compare ScalarValue maps using Arrow ordering - #25555

Merged
viirya merged 1 commit into
apache:mainfrom
viirya:codex/fix-map-scalar-comparison
Sep 21, 2026
Merged

viirya merged 1 commit into
apache:mainfrom
viirya:codex/fix-map-scalar-comparison

Conversation

@viirya

@viirya viirya commented Sep 20, 2026 •

Copy link
Copy Markdown
Member

Which issue does this PR close?

Close #25556

Rationale for this change

ScalarValue::partial_cmp only compared Map keys and ignored their values. Maps with identical keys but different values were therefore considered equal.

This could produce incorrect ordering when merging ordered aggregate states, such as first_value, last_value, and nth_value, and could incorrectly validate range partition split points.

What changes are included in this PR?

Use Arrow's Map comparator for ScalarValue::Map comparisons. This aligns scalar comparison with Arrow sorting and nested comparison semantics, including values, entry order, lengths, and nulls.

Add unit tests covering these cases.

What is the testing strategy for this PR?

Added test_map_partial_cmp covering:

  • maps with identical keys and different values
  • lexicographic (key, value) entry ordering
  • maps of different lengths
  • null and empty maps

Are there any user-facing changes?

Map scalar comparisons now consider both keys and values and are consistent with Arrow ordering.

@github-actions github-actions Bot added the common Related to common crate label Sep 20, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.42857% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.41%. Comparing base (710c748) to head (d51a627).
⚠️ Report is 21 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/common/src/scalar/mod.rs 96.42% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #25555      +/-   ##
==========================================
+ Coverage   82.38%   82.41%   +0.03%     
==========================================
  Files        1138     1138              
  Lines      434313   435420    +1107     
  Branches   434313   435420    +1107     
==========================================
+ Hits       357805   358872    +1067     
+ Misses      54876    54845      -31     
- Partials    21632    21703      +71     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kumarUjjawal kumarUjjawal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @viirya

Looks good 👍

@viirya

viirya commented Sep 21, 2026

Copy link
Copy Markdown
Member Author

Thank you @kumarUjjawal !

@viirya
viirya added this pull request to the merge queue Sep 21, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Sep 21, 2026
@viirya
viirya added this pull request to the merge queue Sep 21, 2026
Merged via the queue into apache:main with commit 0576a0b Sep 21, 2026
42 checks passed
@viirya
viirya deleted the codex/fix-map-scalar-comparison branch September 21, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to common crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ScalarValue::Map comparison ignores map values

3 participants