riverandeye opened a new issue, #2767: URL: https://github.com/apache/iceberg-go/issues/2767
`strictMetricsEval` always returns "might not match" for `startsWith` and `notStartsWith`, even when a file's string bounds prove that every row matches ([`table/evaluators.go`](https://github.com/apache/iceberg-go/blob/9304132dcd647c6b7bc48498f107543bcd21d905/table/evaluators.go#L2042-L2048)): ```go func (m *strictMetricsEval) VisitStartsWith(iceberg.BoundTerm, iceberg.Literal) bool { return rowsMightNotMatch } ``` A filtered delete uses this evaluator to decide whether a data file can be dropped as a whole ([`table/transaction_delete.go`](https://github.com/apache/iceberg-go/blob/9304132dcd647c6b7bc48498f107543bcd21d905/table/transaction_delete.go#L482-L491)). So `Delete(StartsWith(name, "ab"))` on a file where every `name` starts with `"ab"` goes down the rewrite path: the file is read and filtered, and is only removed because no rows are left. The result is correct, but the whole file is read when the stats were enough. Java has used the bounds here since apache/iceberg#15902 ([`StrictEvalVisitor.java`](https://github.com/apache/iceberg/blob/ce1ce419f90354a86ea7a8d7552f8418e4da7a1a/api/src/main/java/org/apache/iceberg/expressions/StrictEvalVisitor.java#L386-L458)): - `startsWith`: rows must match when the column has no nulls and both the lower and upper bound start with the prefix. - `notStartsWith`: rows must match when the column holds only nulls, or when the lower bound (cut to the prefix length) sorts after the prefix, or the upper bound (cut the same way) sorts before it. I ran both strict evaluators on the same stats for an optional string column `name`, on main of each repo (Java ce1ce419f, Go 9304132d): | Filter | Bounds | Java | Go | |---|---|---|---| | `startsWith "ab"` | `abc`..`abd` | must match | might not match | | `notStartsWith "x"` | `abc`..`abd` | must match | might not match | | `notStartsWith "aa"` | `abc`..`abd` | must match | might not match | | `notStartsWith "ab"` | all null | must match | might not match | | `startsWith "ab"` | `abc`..`xyz` | might not match | might not match | | `startsWith "ab"` | `abc`..`abd`, 1 null | might not match | might not match | | `notStartsWith "ab"` | `abc`..`abd` | might not match | might not match | **Proposal:** port Java's `startsWith` and `notStartsWith` to `strictMetricsEval`, with cases in `StrictMetricsTestSuite` matching Java's `TestStrictMetricsEvaluator`. -- 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]
