Skip to content

Implement ST_Extent aggregate (returns Box2D) #2884

@jiayuasu

Description

@jiayuasu

Sub-task of #2877.

Scope

Add the ST_Extent(geom) -> Box2D aggregate. Direct PostGIS counterpart.

Reduces a stream of geometries to the union of their bounding boxes. Returns SQL NULL when there are no rows (or all rows are null/empty geometries) — PostGIS-compatible.

Implementation

  • New ST_Extent aggregator in spark/common/.../expressions/AggregateFunctions.scala, modeled on the existing ST_Envelope_Aggr (same accumulation logic — track running xmin/ymin/xmax/ymax) but returning Box2D instead of an envelope Polygon.
  • Box2D.expandToInclude (already merged in [GH-2877] Add Box2D type and Box2DUDT #2878) is the merge primitive.
  • Catalog registration.
  • Tests: empty input → NULL, single row, mixed empty/non-empty rows, partitioned input.

Out of scope

  • ST_3DExtent (waits for Box3D).
  • Leave ST_Envelope_Aggr untouched for backwards compatibility.

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