diff options
author | mayuanwen <mayuanwen@qiyi.com> | 2015-11-17 11:15:46 -0800 |
---|---|---|
committer | Michael Armbrust <michael@databricks.com> | 2015-11-17 11:15:46 -0800 |
commit | e8833dd12c71b23a242727e86684d2d868ff84b3 (patch) | |
tree | f6173a0fbb1a7c2b54d5778a238f4a52dff40457 /sql/catalyst | |
parent | 21fac5434174389e8b83a2f11341fa7c9e360bfd (diff) | |
download | spark-e8833dd12c71b23a242727e86684d2d868ff84b3.tar.gz spark-e8833dd12c71b23a242727e86684d2d868ff84b3.tar.bz2 spark-e8833dd12c71b23a242727e86684d2d868ff84b3.zip |
[SPARK-11679][SQL] Invoking method " apply(fields: java.util.List[StructField])" in "StructType" gets ClassCastException
In the previous method, fields.toArray will cast java.util.List[StructField] into Array[Object] which can not cast into Array[StructField], thus when invoking this method will throw "java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Lorg.apache.spark.sql.types.StructField;"
I directly cast java.util.List[StructField] into Array[StructField] in this patch.
Author: mayuanwen <mayuanwen@qiyi.com>
Closes #9649 from jackieMaKing/Spark-11679.
Diffstat (limited to 'sql/catalyst')
-rw-r--r-- | sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala index 11fce4beaf..9778df271d 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala @@ -328,7 +328,8 @@ object StructType extends AbstractDataType { def apply(fields: Seq[StructField]): StructType = StructType(fields.toArray) def apply(fields: java.util.List[StructField]): StructType = { - StructType(fields.toArray.asInstanceOf[Array[StructField]]) + import scala.collection.JavaConverters._ + StructType(fields.asScala) } protected[sql] def fromAttributes(attributes: Seq[Attribute]): StructType = |