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


##########
common/src/main/java/org/apache/sedona/common/geometryObjects/Box2D.java:
##########
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sedona.common.geometryObjects;
+
+import java.io.Serializable;
+import java.util.Objects;
+import org.locationtech.jts.geom.Coordinate;
+import org.locationtech.jts.geom.Envelope;
+import org.locationtech.jts.geom.Geometry;
+import org.locationtech.jts.geom.GeometryFactory;
+import org.locationtech.jts.geom.Polygon;
+
+/**
+ * Planar 2D bounding box with min/max X and Y. Empty boxes are encoded as 
{@code xmin > xmax} (JTS
+ * convention), which makes union/expand a no-op against the empty value.

Review Comment:
   The class/Javadoc says empty boxes are encoded as `xmin > xmax`, but 
`isEmpty()` also treats `ymin > ymax` as empty. To avoid ambiguity for API 
consumers, consider updating the doc comment to match the actual emptiness 
predicate (`xmin > xmax || ymin > ymax`).
   



##########
spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/UDT/Box2DUDT.scala:
##########
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.spark.sql.sedona_sql.UDT
+
+import org.apache.sedona.common.geometryObjects.Box2D
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.expressions.GenericInternalRow
+import org.apache.spark.sql.types._
+import org.json4s.JsonAST.JValue
+import org.json4s.JsonDSL._
+
+/**
+ * UDT for [[Box2D]]. Stored as a Spark struct of four non-nullable doubles 
(`xmin`, `ymin`,
+ * `xmax`, `ymax`) so values round-trip natively to Parquet and align with 
GeoParquet 1.1 bbox
+ * covering columns.
+ */
+class Box2DUDT extends UserDefinedType[Box2D] {
+
+  override def sqlType: DataType = StructType(
+    Seq(
+      StructField("xmin", DoubleType, nullable = false),
+      StructField("ymin", DoubleType, nullable = false),
+      StructField("xmax", DoubleType, nullable = false),
+      StructField("ymax", DoubleType, nullable = false)))
+
+  override def pyUDT: String = "sedona.spark.sql.types.Box2DType"

Review Comment:
   `pyUDT` points to `sedona.spark.sql.types.Box2DType`, but there is no 
corresponding Python type in the repository yet. If a Box2D column is ever 
materialized in PySpark (even via a JVM-created DataFrame), this will fail 
during Python UDT resolution. Either add the Python `Box2DType` implementation 
in the same PR, or set `pyUDT` to an existing/valid Python type name (or 
document/guard against Python usage until it exists).
   



##########
spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/UDT/Box2DUDT.scala:
##########
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.spark.sql.sedona_sql.UDT
+
+import org.apache.sedona.common.geometryObjects.Box2D
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.expressions.GenericInternalRow
+import org.apache.spark.sql.types._
+import org.json4s.JsonAST.JValue
+import org.json4s.JsonDSL._
+
+/**
+ * UDT for [[Box2D]]. Stored as a Spark struct of four non-nullable doubles 
(`xmin`, `ymin`,
+ * `xmax`, `ymax`) so values round-trip natively to Parquet and align with 
GeoParquet 1.1 bbox
+ * covering columns.
+ */
+class Box2DUDT extends UserDefinedType[Box2D] {

Review Comment:
   There are existing UDT test suites (e.g., `GeometryUdtTestScala`, 
`RasterUDTSuite`) that validate JSON schema round-tripping and Parquet 
read/write. Adding a new UDT without similar coverage makes it easy to regress 
JSON `class` handling or UDTRegistration behavior. Consider adding a small 
`Box2DUDT` suite that at least checks schema JSON round-tripping and that 
`UdtRegistratorWrapper.registerAll()` registers Box2D.



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