kumarUjjawal commented on code in PR #24781:
URL: https://github.com/apache/datafusion/pull/24781#discussion_r3921338829


##########
datafusion/pruning/src/string_in_list.rs:
##########
@@ -151,19 +184,46 @@ impl PhysicalExpr for StringInListPruningExpr {
                         // uses actual Arrow partition values. 
PrunableStatistics
                         // trusts file providers' bounds: there is no ordering 
gate
                         // for arbitrary statistics providers here.
-                        let index = self.values.partition_point(|v| 
v.as_bytes() < min);
-                        Some(self.values.get(index).is_some_and(|v| 
v.as_bytes() <= max))
+                        match self.membership {
+                            SetMembership::In => {
+                                let index =
+                                    self.values.partition_point(|v| 
v.as_bytes() < min);
+                                Some(
+                                    self.values
+                                        .get(index)
+                                        .is_some_and(|v| v.as_bytes() <= max),
+                                )
+                            }
+                            // A wider interval can always hold a value 
outside the
+                            // domain, which satisfies NOT IN. Only an interval
+                            // pinned to one domain value rules out every row.
+                            // Truncated Parquet bounds cannot fake that: min
+                            // truncates downward and max upward, so equal 
bounds
+                            // mean the true values were equal too. This arm 
also
+                            // compares for equality rather than order, so it 
does
+                            // not rely on the bound ordering the IN arm needs.
+                            SetMembership::NotIn => {
+                                Some(min != max || !self.contains(min))
+                            }
+                        }
                     }
                     // A missing bound makes that end of the interval 
unbounded.
                     // Exclude only when the whole domain lies beyond the 
known bound;
                     // gaps within the domain and equality cannot prove 
disjointness.
+                    // An unbounded interval is never single-valued, so NOT IN 
takes
+                    // neither arm.
                     (Some(min), None)
-                        if self.values.last().is_some_and(|v| v.as_bytes() < 
min) =>
+                        if self.membership == SetMembership::In

Review Comment:
   done!



##########
datafusion/pruning/src/string_in_list.rs:
##########
@@ -151,19 +184,46 @@ impl PhysicalExpr for StringInListPruningExpr {
                         // uses actual Arrow partition values. 
PrunableStatistics
                         // trusts file providers' bounds: there is no ordering 
gate
                         // for arbitrary statistics providers here.
-                        let index = self.values.partition_point(|v| 
v.as_bytes() < min);
-                        Some(self.values.get(index).is_some_and(|v| 
v.as_bytes() <= max))
+                        match self.membership {
+                            SetMembership::In => {
+                                let index =
+                                    self.values.partition_point(|v| 
v.as_bytes() < min);
+                                Some(
+                                    self.values
+                                        .get(index)
+                                        .is_some_and(|v| v.as_bytes() <= max),
+                                )
+                            }
+                            // A wider interval can always hold a value 
outside the
+                            // domain, which satisfies NOT IN. Only an interval
+                            // pinned to one domain value rules out every row.
+                            // Truncated Parquet bounds cannot fake that: min
+                            // truncates downward and max upward, so equal 
bounds
+                            // mean the true values were equal too. This arm 
also
+                            // compares for equality rather than order, so it 
does
+                            // not rely on the bound ordering the IN arm needs.
+                            SetMembership::NotIn => {
+                                Some(min != max || !self.contains(min))

Review Comment:
   done!



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