zeroshade commented on code in PR #2728:
URL: https://github.com/apache/iceberg-go/pull/2728#discussion_r4722330170


##########
table/evaluators.go:
##########
@@ -1399,13 +1403,63 @@ func (m *inclusiveMetricsEval) visitIn(
        return rowsMightMatch
 }
 
-func (m *inclusiveMetricsEval) VisitNotIn(iceberg.BoundTerm, 
iceberg.Set[iceberg.Literal]) bool {
+func (m *inclusiveMetricsEval) VisitNotIn(t iceberg.BoundTerm, s 
iceberg.Set[iceberg.Literal]) bool {
        // because the bounds are not necessarily a min or max value, this 
cannot be
        // answered using them. notIn(col, {X, ...}) with (XX, Y) doesn't 
guarantee that
-       // X is a value in col
+       // X is a value in col, unless every row holds the same value.
+       if value := m.uniqueValue(t); value != nil && s.Contains(value) {
+               return rowsCannotMatch
+       }
+
        return rowsMightMatch
 }
 
+// uniqueValue returns the value every row of the file holds for t, or nil if
+// the stats don't prove that the column has a single value.
+func (m *inclusiveMetricsEval) uniqueValue(t iceberg.BoundTerm) 
iceberg.Literal {

Review Comment:
   Optional: truncated bounds are the main way a single-value check could go 
wrong, and no test pins them down yet. A case like this in 
`TestNotEqualAndNotInSingleValue` would guard against a future writer or 
truncation change that produces equal truncated bounds:
   
   ```go
   long := "abcdefghijklmnopqrstuvwxyz"
   lower := bound(iceberg.StringLiteral(long[:16]))
   upper := bound(iceberg.StringLiteral(internal.TruncateUpperBoundText(long, 
16)))
   // != long[:16] and != long must both keep the file (expected: true)
   ```



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