timothyw553 commented on code in PR #1156:
URL: https://github.com/apache/iceberg-cpp/pull/1156#discussion_r4745302327


##########
src/iceberg/expression/inclusive_metrics_evaluator.cc:
##########
@@ -382,6 +327,38 @@ class InclusiveMetricsVisitor : public BoundVisitor<bool> {
   }
 
  private:
+  template <typename Literals>
+  Result<bool> MayMatchAny(const std::shared_ptr<Bound>& expr, const Literals& 
literals) {
+    const int32_t id = expr->reference()->field().field_id();
+    if (ContainsNullsOnly(id)) {
+      return kRowCannotMatch;
+    }
+    if (literals.size() > kInPredicateLimit) {
+      return kRowsMightMatch;
+    }
+    if (ContainsNaNsOnly(id)) {
+      return std::ranges::any_of(literals, &Literal::IsNaN);
+    }
+
+    ICEBERG_ASSIGN_OR_RAISE(auto lower, LowerBound(expr));
+    ICEBERG_ASSIGN_OR_RAISE(auto upper, UpperBound(expr));
+    if ((lower && lower->IsNaN()) || (upper && upper->IsNaN())) {

Review Comment:
   +1 on settling on one NaN-literal policy here — right now scalar predicates 
reject NaN while vector construction accepts it, and other evaluators would 
need to match if NaN stays allowed.



##########
src/iceberg/expression/inclusive_metrics_evaluator.cc:
##########
@@ -382,6 +327,38 @@ class InclusiveMetricsVisitor : public BoundVisitor<bool> {
   }
 
  private:
+  template <typename Literals>
+  Result<bool> MayMatchAny(const std::shared_ptr<Bound>& expr, const Literals& 
literals) {
+    const int32_t id = expr->reference()->field().field_id();
+    if (ContainsNullsOnly(id)) {
+      return kRowCannotMatch;
+    }
+    if (literals.size() > kInPredicateLimit) {

Review Comment:
   putting `literals.size() > kInPredicateLimit` before `ContainsNaNsOnly(id)` 
means an all-NaN file no longer gets pruned when `IN` has >200 finite literals. 
could we swap those and add a test for that case?
   ```diff
   -    if (literals.size() > kInPredicateLimit) {
   -      return kRowsMightMatch;
   -    }
        if (ContainsNaNsOnly(id)) {
          return std::ranges::any_of(literals, &Literal::IsNaN);
        }
   +    if (literals.size() > kInPredicateLimit) {
   +      return kRowsMightMatch;
   +    }
   ```



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