deepaknettem opened a new pull request, #1177: URL: https://github.com/apache/iceberg-cpp/pull/1177
Follow-up to #1154. ### **Problem** Support for NotStartsWith metadata-based pruning StrictMetricsEvaluator is called from DeleteFiles or OverwriteFiles for metadata-based evaluation / pruning. It checks whether every row in a data file is guaranteed to match the predicate. It is important to make sure we don't have false positives here, otherwise we will have correctness issues. Per the spec, string lower_bounds and upper_bounds are stored in manifest entries as UTF-8 bytes and are drawn only from non-null values. Unlike StartsWith, null values satisfy NotStartsWith, so an all-null column matches and partial nulls or missing null_value_counts do not prevent matching when the non-null bounds fall outside the prefix range. Either bound alone is also sufficient if it rules out the prefix range. **_Edge case:_** Writers can truncate the bounds (for example truncate(16)). Even with truncation, lower_bound <= min and max <= upper_bound still hold in UTF-8 byte order, so both bound checks remain safe without false positives. ### **Fix** Java Reference Implementation: [StrictEvalVisitor.java](https://github.com/apache/iceberg/blob/282ff355692a71e6e974fa96c5ecd8bd9e3d5fe2/api/src/main/java/org/apache/iceberg/expressions/StrictEvalVisitor.java#L426) For NotStartsWith to return true, the column must be a top-level string column reference (not a transform or nested column), and at least one of these must hold: - The column contains nulls only (ContainsNullsOnly). - lower_bound is present and lower > prefix and does not start with prefix (all non-null values are past the prefix range). - upper_bound is present and upper < prefix (all non-null values are strictly before the prefix range). Note: The Java implementation truncates each bound using subSequence(0, Math.min(prefix.length(), bound.length())) before comparing. Checking lower > prefix without a prefix match and upper < prefix directly is equivalent and simpler to follow. ### **Tests** Ported the NotStartsWith tests from Java's [TestStrictMetricsEvaluator.java](https://github.com/apache/iceberg/blob/282ff355692a71e6e974fa96c5ecd8bd9e3d5fe2/api/src/test/java/org/apache/iceberg/expressions/TestStrictMetricsEvaluator.java#L725), plus additional cases: * prefix bounds (above, below, overlapping, equal to lower/upper, proper prefix of prefix, longer prefix, wider range, writer-truncated upper bound, empty prefix) * missing bounds and single bound only (lower-only and upper-only) * all-null columns, mixed nulls with range/equal bounds, and optional columns with missing null counts * nested string columns (without stats, with stats, all nulls) and transform terms * Not(StartsWith(...)) rewrite * multibyte UTF-8 strings * non-string column, non-string literal, and null literal bind rejection -- 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]
