dejankrak-db commented on code in PR #60531:
URL: https://github.com/apache/spark/pull/60531#discussion_r4612939758


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/InterpretedSafeProjection.scala:
##########
@@ -56,7 +57,12 @@ class InterpretedSafeProjection(expressions: 
Seq[Expression]) extends Projection
     (exprs(i), f)
   }
 
-  private def generateSafeValueConverter(dt: DataType): Any => Any = dt match {
+  // A framework type with a row representation is converted as that 
representation.
+  private def generateSafeValueConverter(dt: DataType): Any => Any =
+    
TypeOps(dt).flatMap(_.rowRepresentationType).map(generateSafeValueConverter)

Review Comment:
   Done in cc18d5b3b3f: the array, struct and map converters now check a nested 
value for null before converting it, so a null element, field or map key or 
value is kept. This also fixes the same failure for the built-in StructType. 
The suite covers an array, a map and a struct holding a null value, for the 
type and a UDT over it, in both modes.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala:
##########
@@ -1176,7 +1177,9 @@ case class MapObjects private(
     // Make a copy of the data if it's unsafe-backed
     def makeCopyIfInstanceOf(clazz: Class[_ <: Any], value: String) =
       s"$value instanceof ${clazz.getSimpleName}? ${value}.copy() : $value"
-    val genFunctionValue: String = lambdaFunction.dataType match {
+    // Resolve framework types so that struct-backed types are copied like a 
StructType.
+    val genFunctionValue: String = TypeOps(lambdaFunction.dataType)

Review Comment:
   Done in cc18d5b3b3f: both sites unwrap the UDT before the lookup, so a UDT 
over a struct-backed type is copied, and so is a UDT over a built-in struct. 
The MapObjects and CatalystToExternalMap tests now also run with the UDT.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to