Skip to content

fix: normalize noncanonical NaN literals in comparisons - #5472

Draft
sunchao wants to merge 1 commit into
apache:mainfrom
sunchao:codex/normalize-nan-literals
Draft

fix: normalize noncanonical NaN literals in comparisons#5472
sunchao wants to merge 1 commit into
apache:mainfrom
sunchao:codex/normalize-nan-literals

Conversation

@sunchao

@sunchao sunchao commented Aug 26, 2026

Copy link
Copy Markdown
Member

Which issue does this PR close?

No issue is automatically closed. This is a standalone scalar-comparison normalization fix.

Rationale for this change

Comet normalizes floating-point comparison operands to match Spark's NaN and signed-zero semantics, but the literal fast path skips every float/double literal except negative zero. That also skips NaNs with a different sign or payload. Such literals can therefore retain a different ordering/equality representation from a normalized input column.

What changes are included in this PR?

  • Add !isNaN to the two literal fast-path guards so NaN literals use the existing normalization path.
  • Add float and double regressions using programmatically constructed positive-payload and negative-payload NaNs. They compare Boolean results with Spark, require native projections and filters, and cover both operand orders, nulls, finite values, infinities, and signed zero.

The production change is only the two guards. No normalization refactor, join changes, configuration changes, or new dependency is included. The tests use the default floating-point mode.

How are these changes tested?

Draft: JVM validation is blocked, so no passing JVM test result is claimed.

  • Built a matching native library from public main 5baa6b03.
  • Spotless checks on the final public patch and git diff --check passed.
  • The attempted public Spark 4.0 run stopped during Maven dependency resolution before any tests ran. No repository configuration was changed.
./mvnw test -Pspark-4.0 -Dtest=none \
  -Dsuites=org.apache.comet.CometExpressionSuite \
  '-Dtests=noncanonical NaN literals'

Red/green confirmation of the two new regressions and the existing signed-zero/NaN checks remains required before this draft is ready to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant