deepaknettem opened a new pull request, #1155:
URL: https://github.com/apache/iceberg-cpp/pull/1155

   ### **Problem**
   
   This is a corner-case correctness issue in 
InclusiveMetricsEvaluator::UniqueValue for float and double columns when 
nan_value_counts is unset by a writer. 
   
   Per the Iceberg spec 
(https://iceberg.apache.org/spec/#field-level-metrics-and-statistics), 
lower_bounds and upper_bounds don't consider NaNs, and nan_value_counts is 
optional (a missing entry means unknown, not 0). 
   
   **As an example**: Let's assume a file has only two double values {5.0, NaN} 
with null_value_counts = 0 and nan_value_counts is **not set**.
   
   In this case, both lower and upper bounds are 5.0. The existing 
implementation for UniqueValue is matching it when it should not, and both 
NotEq(col, 5.0) and NotIn(col, {5.0}) incorrectly prune the file.
   
   ### **Fix**
   
   Mostly ported from Java's InclusiveEvalVisitor.uniqueValue / 
InclusiveMetricsEvaluator.mayContainNaN. 
   
   Added a MayContainNaN() helper.
   
   References:
   * Java [uniqueValue]( 
https://github.com/apache/iceberg/blob/main/api/src/main/java/org/apache/iceberg/expressions/InclusiveEvalVisitor.java#L437-L459)
   * Java 
[mayContainNaNs](https://github.com/apache/iceberg/blob/main/api/src/main/java/org/apache/iceberg/expressions/InclusiveMetricsEvaluator.java#L113-L116)
   * C++ 
[CanContainNaNs](https://github.com/apache/iceberg-cpp/blob/main/src/iceberg/expression/strict_metrics_evaluator.cc#L472-L491)
   
   ### **Tests**
   
   Added a new unit test covering both float and double columns across zero, 
empty, missing field ID, and non-zero nan_value_counts and null_value_counts. 
   
   Java TestInclusiveMetricsEvaluator also seems to be missing a test for 
missing nan_value_counts on float/double (but the implementation looks 
correct). We can open a separate test PR in apache/iceberg for the test. 


-- 
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]

Reply via email to