Skip to content

[mosaic] Drop float bounds that can hide NaN or -0.0 - #10730

Closed
thswlsqls wants to merge 1 commit into
apache:masterfrom
thswlsqls:fix/mosaic-float-bounds-nan-signed-zero
Closed

thswlsqls wants to merge 1 commit into
apache:masterfrom
thswlsqls:fix/mosaic-float-bounds-nan-signed-zero

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Purpose

fix #10728

Tests

  • Added MosaicFloatingPointBoundsTest: table reads with NaN-first and signed-zero rows (FLOAT and DOUBLE), asserting the planned split, the row-group read and the filtered result. Red on master at both levels, green now. Single row group only; engine SQL not run.
  • Updated MosaicSimpleStatsExtractorTest expectations.
  • mvn -pl paimon-mosaic clean install: 162 tests, 0 failures.

The native Mosaic writer updates FLOAT/DOUBLE min/max with a partial
comparison: a leading NaN pins both bounds to NaN, a later NaN never
enters the bounds, and -0.0 equals +0.0. Paimon compares bounds with
compareTo, so manifest pruning and row-group pruning could skip files
and row groups that still contain matching rows. Mosaic stats carry no
NaN count, so such bounds cannot be detected and are no longer used.
Null counts are kept.

Generated-by: Claude Code
@JingsongLi

Copy link
Copy Markdown
Contributor

There is an existing-data upgrade gap in the manifest-level fix. MosaicSimpleStatsExtractor drops these bounds when metadata is created, but AppendOnlyFileStoreScan.filterByStats reads the already-persisted entry.file().valueStats() without re-extracting it. Files written before this change can therefore still be pruned before the fixed MosaicRecordsReader is reached.

I reproduced this for both FLOAT and DOUBLE: write [NaN, -5, 3] with the pre-fix extractor behavior and mosaic.stats-columns=v, then read with the fixed behavior and v < 0. Reading the unfiltered split with the fixed reader returns row 2, while the normal filtered scan plans zero splits. The 162 existing module tests pass, but this upgrade regression test fails for both types.

This is a remaining failure of the original bug, rather than a new regression introduced here. Before treating this as a production fix for existing tables, please cover persisted unsafe manifest statistics as well, or explicitly document the limitation and a verified procedure for rebuilding the affected metadata/data. Please add a test that writes legacy bounds and reads them with the fix; the current tests write all metadata using the new extractor.

@JingsongLi

Copy link
Copy Markdown
Contributor

No one has actually encountered a "NaN" issue; stop trying to use AI to "fix" such problems—unless you are genuinely facing them in a production environment.

@JingsongLi JingsongLi closed this Oct 22, 2026
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.

[Bug] Mosaic FLOAT/DOUBLE stats can skip rows when data contains NaN or -0.0

2 participants