Skip to content

Implement ST_Box2D(geom) scalar function #2881

@jiayuasu

Description

@jiayuasu

Sub-task of #2877.

Scope

Add the ST_Box2D(geom) -> Box2D scalar function. PostGIS calls this Box2D(geometry); we use the ST_ prefix for consistency with the rest of the Sedona surface.

Returns the planar bounding box of the input geometry, or SQL NULL for null/empty input (PostGIS-compatible). Backed by Box2D.fromGeometry(Geometry) (already merged in #2878).

Implementation

  • New ST_Box2D case class in spark/common/.../expressions/Functions.scala extending InferredExpression.
  • Add Box2D mappings in InferredExpression.scala (InferrableType[Box2D] instance, output serializer that turns a Box2D into a struct InternalRow, and Box2DUDT in the Spark return-type mapping).
  • Register the function in spark/common/.../UDF/Catalog.scala.
  • Test coverage: scalar over point/linestring/polygon, null input, empty geometry input, schema check.

Out of scope

ST_MakeBox2D, ST_Extent, accessor overloads, casts — separate child issues under #2877.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions