MaxGekk commented on PR #56104:
URL: https://github.com/apache/spark/pull/56104#issuecomment-4593110413

   **`setSrid` silently drops the write when the `BinaryView` isn't a tight 
on-heap owner**
   
   `Geometry.setSrid` / `Geography.setSrid` mutate the header through 
`getWrapper()`, i.e. `ByteBuffer.wrap(getBytes())`. But `BinaryView.getBytes()` 
only returns the live backing array when the view is a tight on-heap owner; for 
a `slice`, a sub-range (`fromBytes(bytes, offset, numBytes)`), or an off-heap 
view it returns a fresh copy. In those cases `setSrid` mutates a throwaway 
buffer and the SRID change is lost with no error, and `srid()` keeps returning 
the old value. The old `GeometryVal` always wrapped a tight `byte[]`, so this 
is a new sharp edge introduced by the migration.
   
   It's safe today only because the sole caller (`STUtils.stGeomSetSrid` / 
`stGeogSetSrid`) does `.copy()` first, which guarantees a tight array. But 
anyone calling `setSrid` on a `Geometry`/`Geography` built via 
`fromValue(view)` over a non-tight view gets a silent no-op. Could we make this 
fail loudly (or write through to the live buffer) so misuse can't pass silently?


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