You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "dongjoon-hyun (via GitHub)" <gi...@apache.org> on 2024/03/23 23:57:54 UTC

Re: [PR] [SPARK-47528][SQL] Add UserDefinedType support to DataTypeUtils.canWrite [spark]

dongjoon-hyun commented on code in PR #45678:
URL: https://github.com/apache/spark/pull/45678#discussion_r1536710291


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/types/DataTypeUtils.scala:
##########
@@ -180,6 +180,16 @@ object DataTypeUtils {
       case (w, r) if DataTypeUtils.sameType(w, r) && !w.isInstanceOf[NullType] =>
         true
 
+      // If write-side data type is a user-defined type, check with its underlying data type.
+      case (w, r) if w.isInstanceOf[UserDefinedType[_]] && !r.isInstanceOf[UserDefinedType[_]] =>
+        canWrite(tableName, w.asInstanceOf[UserDefinedType[_]].sqlType, r, byName, resolver,
+          context, storeAssignmentPolicy, addError)
+
+      // If read-side data type is a user-defined type, check with its underlying data type.
+      case (w, r) if r.isInstanceOf[UserDefinedType[_]] && !w.isInstanceOf[UserDefinedType[_]] =>
+        canWrite(tableName, w, r.asInstanceOf[UserDefinedType[_]].sqlType, byName, resolver,
+          context, storeAssignmentPolicy, addError)

Review Comment:
   It seems that we need to update the method description accordingly. Could you update it with this new feature, @viirya ?
   
   https://github.com/apache/spark/blob/39500a315166d8e342b678ef3038995a03ce84d6/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/types/DataTypeUtils.scala#L59-L67



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org