deepaknettem opened a new pull request, #1186: URL: https://github.com/apache/iceberg-cpp/pull/1186
### Problem Writers like ORC can record NaN for both lower and upper bounds when the first value in a float/double column is NaN, even if finite values are present later in the file. When that value is -NaN (for example, 0.0 / 0.0 on x86-64), pruning is incorrect. I added unit tests setting upper_bounds to -NaN to confirm my suspicion and saw them fail. Java implementation checks isNaN(lower) only because Float.compare / Double.compare collapses -NaN to +NaN at the time of comparison, so it doesn't need to handle this case. I saw the PyIceberg implementation, and it is also doing an explicit check on upper_bounds with a comment to that effect ([visitors.py#L1415-L1417](https://github.com/apache/iceberg-python/blob/fb317b2ad7cf3e144d38a972f4e3c2ab31039598/pyiceberg/expressions/visitors.py#L1415-L1417)). In existing implementation, -NaN upper bound causes both upper < lit and upper <= lit evaluate true, so without an explicit check for -NaN, - InclusiveMetricsEvaluator: Gt, GtEq, Eq, and In return **false**, skipping files that may match. - StrictMetricsEvaluator: Lt, LtEq, NotEq, and NotIn return **true**, and could be dropping files. References: * [Java StrictEval](https://github.com/apache/iceberg/blob/main/api/src/main/java/org/apache/iceberg/expressions/StrictEvalVisitor.java#L155-L202) * [Java InclusiveEval](https://github.com/apache/iceberg/blob/main/api/src/main/java/org/apache/iceberg/expressions/InclusiveEvalVisitor.java#L211-L279) ### Fix - Check `upper->IsNaN()` in InclusiveMetricsEvaluator (Gt, GtEq, Eq, In) and return `kRowsMightMatch`. - Check `upper.IsNaN()` in StrictMetricsEvaluator (Lt, LtEq, NotEq, NotIn) and return `kRowsMightNotMatch`. ### Tests - Added basic unit tests. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
