diff options
author | gmoehler <moehler@de.ibm.com> | 2017-01-25 08:17:24 -0800 |
---|---|---|
committer | gatorsmile <gatorsmile@gmail.com> | 2017-01-25 08:17:24 -0800 |
commit | f6480b1467d0432fb2aa48c7a3a8a6e6679fd481 (patch) | |
tree | f06a7086c4702b65e27ac51dff79244f8c4256ac /sql/catalyst | |
parent | f1ddca5fcc1e914b9efb8a634ea7c89407358ea6 (diff) | |
download | spark-f6480b1467d0432fb2aa48c7a3a8a6e6679fd481.tar.gz spark-f6480b1467d0432fb2aa48c7a3a8a6e6679fd481.tar.bz2 spark-f6480b1467d0432fb2aa48c7a3a8a6e6679fd481.zip |
[SPARK-19311][SQL] fix UDT hierarchy issue
## What changes were proposed in this pull request?
acceptType() in UDT will no only accept the same type but also all base types
## How was this patch tested?
Manual test using a set of generated UDTs fixing acceptType() in my user defined types
Please review http://spark.apache.org/contributing.html before opening a pull request.
Author: gmoehler <moehler@de.ibm.com>
Closes #16660 from gmoehler/master.
Diffstat (limited to 'sql/catalyst')
-rw-r--r-- | sql/catalyst/src/main/scala/org/apache/spark/sql/types/UserDefinedType.scala | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/types/UserDefinedType.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/types/UserDefinedType.scala index c33219c95b..5a944e763e 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/types/UserDefinedType.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/types/UserDefinedType.scala @@ -78,8 +78,12 @@ abstract class UserDefinedType[UserType >: Null] extends DataType with Serializa */ override private[spark] def asNullable: UserDefinedType[UserType] = this - override private[sql] def acceptsType(dataType: DataType) = - this.getClass == dataType.getClass + override private[sql] def acceptsType(dataType: DataType) = dataType match { + case other: UserDefinedType[_] => + this.getClass == other.getClass || + this.userClass.isAssignableFrom(other.userClass) + case _ => false + } override def sql: String = sqlType.sql |