HyukjinKwon commented on a change in pull request #26644: [SPARK-30004][SQL]
Allow merge UserDefinedType into a native DataType
URL: https://github.com/apache/spark/pull/26644#discussion_r363131450
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala
##########
@@ -592,6 +597,12 @@ object StructType extends AbstractDataType {
case (leftUdt: UserDefinedType[_], rightUdt: UserDefinedType[_])
if leftUdt.userClass == rightUdt.userClass => leftUdt
+ case (leftType, rightUdt: UserDefinedType[_])
+ if leftType == rightUdt.sqlType => leftType
+
+ case (leftUdt: UserDefinedType[_], rightType)
+ if leftUdt.sqlType == rightType => rightType
Review comment:
> it is allowed to merge an int into a long.
But this `StructType.merge` does not allow such type merging. Given that, it
looks weird to allow only UDT.
```scala
scala> import org.apache.spark.sql.types._
import org.apache.spark.sql.types._
scala> StructType.merge(LongType, IntegerType)
org.apache.spark.SparkException: Failed to merge incompatible data types
bigint and int
at org.apache.spark.sql.types.StructType$.merge(StructType.scala:600)
... 49 elided
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]