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


##########
spark/common/src/main/scala/org/apache/sedona/sql/UDF/Catalog.scala:
##########
@@ -278,6 +278,7 @@ object Catalog extends AbstractCatalog with Logging {
   // Bounding-Box-Functions
   val boundingBoxExprs: Seq[FunctionDescription] = Seq(
     function[ST_BoundingDiagonal](),
+    function[ST_Box2D](),

Review Comment:
   Registering the expression here only exposes `ST_Box2D` to SQL. Unlike the 
neighboring geometry functions such as `ST_Envelope`/`ST_BoundingDiagonal`, 
there is no corresponding `st_functions.ST_Box2D(...)` wrapper, so the new 
user-facing function is unavailable through the Scala DataFrame/Column API 
unless callers drop down to `expr(...)`.



##########
spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/InferredExpression.scala:
##########
@@ -266,6 +269,12 @@ object InferredTypes {
       } else {
         null
       }
+    } else if (t =:= typeOf[Box2D]) { output =>
+      if (output != null) {
+        Box2DUDT().serialize(output.asInstanceOf[Box2D])
+      } else {
+        null
+      }

Review Comment:
   `buildSerializer` runs once per evaluated row, so calling `Box2DUDT()` here 
allocates a fresh UDT object for every `Box2D` result. On large scans this 
creates a lot of avoidable garbage in the hot path; it's better to reuse the 
singleton/capture one serializer instance outside the closure.
   



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