You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sedona.apache.org by "jiayuasu (via GitHub)" <gi...@apache.org> on 2026/05/02 05:30:39 UTC

[I] [GH-2877] Add CAST(box2d AS geometry) and ST_AsText(box2d) [sedona]

jiayuasu opened a new issue, #2885:
URL: https://github.com/apache/sedona/issues/2885

   Sub-task of #2877.
   
   ## Scope
   
   Two related conversions:
   
   1. **CAST(box2d AS geometry)** — convert a `Box2D` to a closed rectangular `Polygon` (PostGIS `box2d::geometry`). Decision point: register as a Catalyst implicit cast, or expose as an explicit function (e.g. `ST_Geometry(box2d)` or reuse `ST_Polygon(box2d)`). PostGIS uses an implicit cast; Spark Catalyst makes UDT-to-UDT implicit casts non-trivial. Pick the cleanest path during implementation.
   2. **ST_AsText(box2d)** — format as `BOX(x1 y1, x2 y2)`. PostGIS-compatible string. Overload the existing `ST_AsText` to accept a `Box2D` argument.
   
   ## Implementation
   
   - Polygon construction helper either as a static method on `Box2D` (revives the prior `toPolygon()`) or next to the cast expression.
   - Cast registration via Catalyst (`Cast.canCast` extension or rule), or function registration if we go the explicit-function route.
   - `ST_AsText` overload in `Functions.scala` (already polymorphic for Geometry/Geography); add a `Box2D` branch.
   - Tests: cast round-trip (`ST_Box2D(geom).cast(Geometry)` ≈ `ST_Envelope(geom)` for valid geometries), ST_AsText format, NULL propagation.
   
   ## Out of scope
   
   `ST_GeomFromText('BOX(...)')` reverse parser — separate need, not part of this issue.


-- 
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: issues-unsubscribe@sedona.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Add CAST(box2d AS geometry) and ST_AsText(box2d) [sedona]

Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu closed issue #2885: Add CAST(box2d AS geometry) and ST_AsText(box2d)
URL: https://github.com/apache/sedona/issues/2885


-- 
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: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org