You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[C++][Dataset] Negated comparison with a NaN literal skips row groups with Parquet statistics #55947
Describe the bug, including details regarding any error messages, version, and platform.
A dataset filter of the form ~(x < NaN) or ~(x <= NaN) returns no rows when Parquet statistics are present, although it is true for every non-null row. In memory and without statistics the rows are returned. The column does not need to contain NaN, and integer columns compared through a cast are affected too.
~(x > NaN), ~(x >= NaN), x != NaN and ~(x == NaN) return the correct 2 rows.
Cause, from reading the code: Comparison::Execute in cpp/src/arrow/compute/expression_internal.h calls equal and then less, and returns GREATER when both are false. For a NaN literal both are false, so NaN is treated as greater than the statistics bound. Inequality::Simplify in expression.cc then sees the guarantee x <= 3 and the filter x < NaN with cmp_rhs_bound == GREATER and simplifies the filter to true. That is harmless on its own, because the filter is still evaluated per row, but under invert it becomes false and the row group is skipped. With a x >= min bound the same code bails out, which is why >/>= are not affected.
A possible fix: have Comparison::Execute also call greater and return NA when the values are unordered, and have Inequality::Simplify return the expression unchanged on NA (it currently only has DCHECK_NE(cmp_rhs_bound, Comparison::NA)). Alternatively, do not simplify comparisons whose literal is NaN.
Related but different: GH-51491 is about NaN values in the data that are not part of min/max. Here the data has no NaN; the NaN is in the literal, and fixing GH-51491 by widening the guarantee for float columns would not cover the integer case above.
Reproduces on pyarrow 10.0.1, 13.0.0, 16.1.0, 18.1.0, 22.0.0 and 26.0.1 (Linux x86_64, Python 3.11). The code is unchanged on main.
Component(s)
C++, Python
Drafted with Claude Code; reproduced and reviewed by me.
Activity