vishnuprakaz opened a new pull request, #17493:
URL: https://github.com/apache/iceberg/pull/17493

   While reading the v4 stats code noticed [comment on 
#17322](https://github.com/apache/iceberg/pull/17322#discussion_r3661053867) 
suspecting that `Conversions.toByteBuffer` might not handle geometry bounds 
properly inside `ContentStatsBackedMap.bound()`. The suspicion is correct. For 
geometry and geography columns, the bound field in the stats schema is the 
bounding-box struct (x, y, z, m) built by `StatsUtil.geoLowerBound`, and 
`Conversions.toByteBuffer` has no struct case, so it throws. 
   
   A small repro against current main confirmed it:
   
   ```
     java.lang.UnsupportedOperationException: Cannot serialize type: STRUCT
         at 
org.apache.iceberg.types.Conversions.toByteBuffer(Conversions.java:145)
         at 
org.apache.iceberg.ContentStatsBackedMap.bound(ContentStatsBackedMap.java:169)
         at 
org.apache.iceberg.ContentStatsBackedMap.get(ContentStatsBackedMap.java:87)
     ```
   
     Once a tracked file carries geo column stats, any access to 
`lowerBounds()` or `upperBounds()` that touches the geo column hits this a 
predicate on that column, or anything that copies or iterates the stats maps. 
Nothing reaches this in production today, but #17433 starts reading geo stats 
from v4 manifests, which puts the crash one call away from the read
   path.
   
     The fix converts the bounding-box struct back to a `GeospatialBound` and 
serializes it with the spec's single-point bound encoding. That's the 
representation legacy consumers of these maps already expect: `Conversions` 
reads that encoding back for geo types, and v3 tables surface geo bounds 
through the same maps in the same form so the legacy view of a
     v4 file stays consistent with v3 behavior, and the bounding-box storage 
format from the v4 stats design is untouched.
   
     Tests cover geometry and geography columns next to a primitive column, the 
z-only and m-only encodings, a geo field with no lower bound, and a round-trip 
through `Conversions.fromByteBuffer`.
   
     If this is already covered as part of the planned content-stats 
integration work, happy to fold it into that instead.


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