Skip to content

fix: use to_bits() comparison for float types in eq_array (#24431) - #24436

Closed
waterWang wants to merge 1 commit into
apache:mainfrom
waterWang:fix/scalar-eq-array-float-to-bits
Closed

fix: use to_bits() comparison for float types in eq_array (#24431)#24436
waterWang wants to merge 1 commit into
apache:mainfrom
waterWang:fix/scalar-eq-array-float-to-bits

Conversation

@waterWang

Copy link
Copy Markdown

Problem

ScalarValue::eq_array is documented as an optimized equivalent of extracting an array element with ScalarValue::try_from_array and comparing the resulting scalars. However, for floating-point values eq_array uses IEEE equality (via the generic eq_array_primitive! macro) while ScalarValue::PartialEq compares bit representations, producing inconsistent results:

  • Identical NaN bit patterns compare equal as ScalarValues but unequal through eq_array.
  • +0.0 and -0.0 compare unequal as ScalarValues but equal through eq_array.

Fix

Replace the Float16, Float32, and Float64 branches of eq_array with custom to_bits() comparison, matching the semantics of ScalarValue::PartialEq for floats.

Closes #24431

@github-actions github-actions Bot added the common Related to common crate label Aug 17, 2026
@Jefffrey

Copy link
Copy Markdown
Contributor

@Jefffrey Jefffrey closed this Aug 18, 2026
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::eq_array is inconsistent with ScalarValue equality for floating-point values

2 participants