Skip to content

fix: account for NaN in float stats exported to DuckDB and DataFusion - #10479

Merged
robert3005 merged 1 commit into
vortex-data:developfrom
jackylee-ch:fix/nan-aware-float-stats
Oct 16, 2026
Merged

robert3005 merged 1 commit into
vortex-data:developfrom
jackylee-ch:fix/nan-aware-float-stats

Conversation

@jackylee-ch

@jackylee-ch jackylee-ch commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

What

Vortex's min, max and sum statistics skip NaN, but the DuckDB and DataFusion integrations report
them to the engine as exact bounds over every value. On a float column holding NaN, both engines
then answer from the statistics:

  • SELECT max(x) returns the largest non-NaN value instead of NaN;
  • WHERE x = 'NaN' returns no rows (DuckDB plans an EMPTY_RESULT, DataFusion prunes the file);
  • in DataFusion, where a negative NaN sorts below every value, WHERE x < 0.5 drops it as well.

Fix

Check the footer's exact NaNCount. DuckDB sorts NaN above every value, so its max becomes NaN
when the count is non-zero and is left out when the count is unknown; min is already correct.
DataFusion sorts NaN by sign, so min, max and sum are reported only for a NaN-free column (this
also guards the v2 source, which reports no statistics yet). Other columns are unchanged; float
columns in files from before NaNCount (0.29 to 0.32) lose their bounds.

The new NaN cases fail on develop (max(x) returns 2, the NaN filters return no rows); two plan
checks pin that NaN-free float columns are still answered from statistics.

constant_distinct_count (from #10448) now reuses is_nan_free. #10265 and #9775 rewrite these
functions.

AI assistance

Written with agentic AI assistance; each failure above was reproduced on develop before the fix.

Vortex's min, max and sum statistics skip NaN. Report them to DataFusion
only for a column whose footer NaNCount is exactly zero, and give DuckDB a
NaN max when the column holds NaN.

Signed-off-by: jackylee-ch <qcsd2011@gmail.com>
Signed-off-by: Robert Kruszewski <github@robertk.io>
@robert3005
robert3005 force-pushed the fix/nan-aware-float-stats branch from da90c5b to f2b1771 Compare October 15, 2026 17:36
@robert3005 robert3005 added the changelog/fix A bug fix label Oct 16, 2026
@codspeed

codspeed Bot commented Oct 16, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 12.92%

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚠️ 1 benchmark measured no execution time

Nothing ran under measurement, usually because the compiler removed the code under test. This result is not comparable, so it counts as unchanged.

Preventing compiler optimizations

⚠️ 34 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

ℹ️ 40 benchmarks have no flame graph

The flamegraph could not be generated because we failed to resolve the symbols in the profiling trace. This happens when we fail to harvest information about language frames.

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 3 regressed benchmarks
✅ 2256 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ ⚠️ Simulation test_scan_scalar_at[int_float] 968.1 µs 1,150.6 µs -15.86%
❌ WallTime bitpack_blocked_compress_avx2 6.7 µs 7.6 µs -11.6%
❌ ℹ️ Simulation test_scan_filter[int] 3 ms 3.4 ms -11.23%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing jackylee-ch:fix/nan-aware-float-stats (f2b1771) with develop (e8974d6)

Open in CodSpeed

@robert3005
robert3005 merged commit 7e3ea09 into vortex-data:develop Oct 16, 2026
130 of 134 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants