[GH-2882] Overload ST_XMin/XMax/YMin/YMax for Box2D#2895
Merged
Conversation
Adds Box2D variants of the four 2D accessors so users can read axis bounds directly off a bbox value, e.g. ST_XMin(ST_Box2D(geom)). PostGIS-compatible. Also adds the Box2D input-side plumbing in InferredExpression: the toBox2D extractor in implicits, and the typeOf[Box2D] branch in buildArgumentExtractor. Future Box2D-consuming functions (cast, ST_AsText, predicates) plug in by reusing this scaffolding. Closes apache#2882.
jiayuasu
added a commit
to jiayuasu/sedona
that referenced
this pull request
May 5, 2026
Mirrors the Phase 1 SQL surface added in apache#2890, apache#2895, apache#2897, apache#2898, apache#2899 in PySpark wrappers: - ST_Box2D in st_functions - ST_MakeBox2D and ST_GeomFromBox2D in st_constructors - ST_Extent in st_aggregates Accessor overloads (ST_XMin/XMax/YMin/YMax) and ST_AsText already worked with Box2D inputs through their existing wrappers; SQL overload resolution happens on the JVM side. The Python Box2DType UDT and Box2D value class were merged in apache#2878, so collected results materialize as Box2D Python objects with xmin/ymin/xmax/ymax attributes. Closes apache#2887.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Did you read the Contributor Guide?
Is this PR related to a ticket?
[GH-XXX] my subject. Closes Overload ST_XMin/XMax/YMin/YMax for Box2D #2882What changes were proposed in this PR?
Overloads the four 2D coordinate accessors (
ST_XMin,ST_XMax,ST_YMin,ST_YMax) to accept aBox2Dargument in addition to the existingGeometryargument. PostGIS-compatible.common/.../Functions.java— newxMin/xMax/yMin/yMax(Box2D)overloads (each is a NULL-safe field accessor).spark/common/.../expressions/Functions.scala— the fourST_*case classes now extendInferredExpressionwith two overloaded function references (Geometry + Box2D).FunctionResolverpicks the right backing function based on the input type at planning time.spark/common/.../expressions/implicits.scala—toBox2D(input: InternalRow)extractor that handles the struct UDT representation.spark/common/.../expressions/InferredExpression.scala—typeOf[Box2D]branch inbuildArgumentExtractor.The output-side plumbing (
InferrableType[Box2D], struct serializer, Spark return-type mapping) was added in #2890. This PR adds the symmetrical input-side plumbing. Future Box2D-consuming functions (cast to geometry,ST_AsText, future predicates) plug in by reusing this scaffolding.How was this patch tested?
functionTestScala(added "Passed ST_XMin / XMax / YMin / YMax for Box2D"):The existing Geometry-input tests continue to exercise the original overloads.
Did this PR include necessary documentation updates?
ST_MakeBox2D,ST_Extent, and the cast/text functions exist. Scala DataFrame API wrappers tracked separately in Scala/Python DataFrame API wrappers for Box2D Phase 1 functions #2891.