riverandeye opened a new pull request, #2709:
URL: https://github.com/apache/iceberg-go/pull/2709

   Fixes #2708
   
   A data file whose string or binary column has `""` (or empty binary) as its 
minimum or maximum was written without that bound. If every value in the file 
was empty, the file got neither bound, so scans with filters such as `s = 'zz'` 
or `s > 'a'` could not skip it. Java writes empty bounds for the same rows.
   
   ### Cause
   
   An empty value serializes to zero bytes. `ToDataFile` recorded a bound only 
when `len(...) > 0`, so it could not tell an empty bound from no bound. 
`MaxAsBytes` had the same problem: it treated an empty truncation result as "no 
upper bound could be found", even when the max was `""` and nothing was 
truncated.
   
   ### Fix
   
   - `ToDataFile` records a bound whenever `MinAsBytes` / `MaxAsBytes` return a 
non-nil slice. `nil` still means no bound. The geo and decimal aggregators 
already return `nil` when they have no bound.
   - `toBytes` returns a non-nil empty slice for an empty value. 
`BinaryLiteral.MarshalBinary` can return `nil` for empty input.
   - `MaxAsBytes` returns the max unchanged when it isn't truncated, and 
returns `nil` only when truncation found no greater prefix (for example a 
prefix made only of U+10FFFF or `0xFF` bytes).
   
   ### Tests
   
   - `TestEmptyStringAndBinaryBounds` builds Parquet stats for all-empty 
columns, a column whose minimum is empty, full metrics mode, and a truncated 
max with no greater prefix.
   - `TestEmptyStringBoundsPruneScans` appends rows whose string column is all 
`""` and checks that the file keeps both bounds and is skipped for `s = 'zz'` 
and `s > 'a'`.
   
   Both tests fail on main without the change. `go test ./...` and 
`golangci-lint run ./table/ ./table/internal/` pass.
   
   I also wrote the same rows with Iceberg Java and compared the manifests with 
a plain Avro reader. With this change, the `lower_bounds` and `upper_bounds` 
entries for the string and binary columns match Java's.
   


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