Repository navigation
fix(expr): treat NaN row group bounds as might-match for inequalities - #3502
Conversation
JeonDaehong
left a comment
There was a problem hiding this comment.
Checked this locally. The is_nan() check covers both ends: with sign-bit NaN bounds (0xffc0_0000), main also prunes > and >= (see inline), so the fix matters there too, not only for < / <=.
PageIndexEvaluator::visit_inequality (page_index_evaluator.rs:575) has the same shape. It checks only the literal for NaN before comparing the page min/max. I haven't built a page index with NaN bounds to confirm it, so this is from reading the code, but it might be worth the same guard or a follow-up.
| } | ||
|
|
||
| #[test] | ||
| fn eval_true_for_nan_upper_bound_greater_than() -> Result<()> { |
There was a problem hiding this comment.
These pass on main too, since a positive NaN max is above 5.0 under total_cmp. A NaN with the sign bit set sorts below -Inf instead. With min = max = f32::from_bits(0xffc0_0000), main prunes the row group for f > 5.0 and f >= 5.0, and this PR keeps it. I checked by dropping the new is_nan() block. Running these two tests (or all four) with that bound as well would pin the upper-bound half of the fix.
There was a problem hiding this comment.
Thanks for checking. In 93ebac6 all four tests now run with both f32::NAN and f32::from_bits(0xffc0_0000) as min/max. Without the is_nan() block all four fail, so the > / >= half is pinned too. I will look at PageIndexEvaluator::visit_inequality separately rather than widen this PR. (AI-assisted reply.)
laskoviymishka
left a comment
There was a problem hiding this comment.
Thanks for the quick follow-up. Running each test with both NaN signs means the >/>= half of the check now has a test that fails on main too. The fix looks right to me: it checks the one bound each operator reads, the same way eq and in already do. I left one small optional test ask inline.
@anoopj or @blackmwk, could one of you also take a look at the evaluator change when you get a chance?
| 1, | ||
| 1, | ||
| Some(Statistics::float( | ||
| Some(nan), |
There was a problem hiding this comment.
Could the helper take min and max separately, so we can add a < case with a NaN min and a finite max, e.g. (f32::NAN, 2.0)? It's the same branch, since </<= only read the min. But it pins that a finite max doesn't change the result, the way eval_true_for_meta_lower_nan_filter_eq does for eq.
There was a problem hiding this comment.
Done in a133ee8. The helper now takes min and max separately, and eval_true_for_nan_lower_bound_finite_upper_bound_less_than checks < and <= with (NaN, 2.0) for both NaN signs. It fails without the is_nan() check. (AI-assisted reply.)
|
This is good to merge to me, thanks 🌬️ ⛵ |
|
@ump45nose welcome to contributors team! |
Which issue does this PR close?
<and<=matches when the min statistic is NaN #3494.What changes are included in this PR?
RowGroupMetricsEvaluator::visit_inequalityonly checked the literal for NaN. When a row group's min statistic was NaN (parquet-mr 1.9 and earlier record a NaN that starts a row group as both min and max),f < 5.0andf <= 5.0pruned the row group even though it could hold smaller values.This makes
visit_inequalityreturn might-match when the bound it compares against is NaN, the same wayeqandinin this evaluator already treat a NaN bound as unreliable.Are these changes tested?
Yes. Four new tests in
row_group_metrics_evaluator.rsevaluate<,<=,>and>=against a row group whose min and max are both NaN. The<and<=tests fail onmain(219571a) and pass with the fix; the>/>=ones already pass (a NaN max compares greater than the literal) and are there to pin the behaviour for both bounds.cargo test -p iceberg --lib expr::visitorsandcargo clippy -p iceberg --all-targets -- -D warningspass locally.AI Disclosure
I used an AI assistant to help write the fix and tests, then reviewed the change and ran the tests myself.