Copilot commented on code in PR #2897:
URL: https://github.com/apache/sedona/pull/2897#discussion_r3178552148


##########
spark/common/src/test/scala/org/apache/sedona/sql/constructorTestScala.scala:
##########
@@ -138,6 +139,42 @@ class constructorTestScala extends TestBaseScala with 
Matchers {
       assert(polygonDF.count() == 1)
     }
 
+    it("Passed ST_MakeBox2D") {
+      val df = sparkSession.sql("""
+        SELECT
+          ST_MakeBox2D(ST_Point(1.0, 2.0), ST_Point(4.0, 5.0))           AS 
bbox,
+          ST_MakeBox2D(ST_Point(10.0, 20.0), ST_GeomFromText(NULL))       AS 
bbox_null,
+          ST_MakeBox2D(ST_GeomFromText('POINT EMPTY'), ST_Point(1.0, 1.0)) AS 
bbox_empty
+      """)
+      val row = df.collect()(0)
+      val bbox = row.getAs[Box2D]("bbox")
+      assert(bbox.getXMin == 1.0)
+      assert(bbox.getYMin == 2.0)
+      assert(bbox.getXMax == 4.0)
+      assert(bbox.getYMax == 5.0)
+      assert(row.isNullAt(1))
+      assert(row.isNullAt(2))
+    }
+
+    it("ST_MakeBox2D preserves swapped corners") {
+      // No swapping or reordering; lower-left/upper-right are taken verbatim.
+      // This leaves xmin > xmax / ymin > ymax available for future 
antimeridian semantics.
+      val df = sparkSession.sql(
+        "SELECT ST_MakeBox2D(ST_Point(170.0, 10.0), ST_Point(-170.0, 20.0)) AS 
bbox")
+      val bbox = df.collect()(0).getAs[Box2D]("bbox")
+      assert(bbox.getXMin == 170.0)
+      assert(bbox.getXMax == -170.0)
+    }

Review Comment:
   Tests cover happy path, null propagation, empty point, swapped corners, and 
non-point rejection, but they don’t cover the 3D POINT case mentioned in the 
issue (e.g., ST_PointZ / ST_MakePoint(x,y,z)). Since ST_MakeBox2D should ignore 
Z and use X/Y verbatim, add an assertion that a 3D point input returns the 
expected xmin/ymin/xmax/ymax (and doesn’t error).



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

Reply via email to