spark-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Apache Spark (JIRA)" <j...@apache.org>
Subject [jira] [Assigned] (SPARK-21204) RuntimeException with Set and Case Class in Spark 2.1.1
Date Sun, 25 Jun 2017 10:45:01 GMT

     [ https://issues.apache.org/jira/browse/SPARK-21204?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Apache Spark reassigned SPARK-21204:
------------------------------------

    Assignee:     (was: Apache Spark)

> RuntimeException with Set and Case Class in Spark 2.1.1
> -------------------------------------------------------
>
>                 Key: SPARK-21204
>                 URL: https://issues.apache.org/jira/browse/SPARK-21204
>             Project: Spark
>          Issue Type: Bug
>          Components: Optimizer, SQL
>    Affects Versions: 2.1.1
>            Reporter: Leo Romanovsky
>
> When attempting to produce a Dataset containing a Set, such as with:
> {code:java}
> dbData
>   .groupBy("userId")
>   .agg(functions.collect_set("friendId") as "friendIds")
>   .as[(Int, Set[Int])]
> {code}
> An exception occurs. This can be avoided by casting to a Seq, but sometimes it makes
more logical sense have a Set, especially when using the collect_set aggregation operation.
Additionally, I am unable to write this Dataset to a Cassandra table containing a Set column
without first converting to an RDD.
> {code:java}
> [error] Exception in thread "main" java.lang.UnsupportedOperationException: No Encoder
found for Set[Int]
> [error] - field (class: "scala.collection.immutable.Set", name: "_2")
> [error] - root class: "scala.Tuple2"
> [error] 	at org.apache.spark.sql.catalyst.ScalaReflection$.org$apache$spark$sql$catalyst$ScalaReflection$$serializerFor(ScalaReflection.scala:602)
> [error] 	at org.apache.spark.sql.catalyst.ScalaReflection$$anonfun$9.apply(ScalaReflection.scala:596)
> [error] 	at org.apache.spark.sql.catalyst.ScalaReflection$$anonfun$9.apply(ScalaReflection.scala:587)
> [error] 	at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:252)
> [error] 	at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:252)
> [error] 	at scala.collection.immutable.List.foreach(List.scala:381)
> [error] 	at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:252)
> [error] 	at scala.collection.immutable.List.flatMap(List.scala:344)
> [error] 	at org.apache.spark.sql.catalyst.ScalaReflection$.org$apache$spark$sql$catalyst$ScalaReflection$$serializerFor(ScalaReflection.scala:587)
> [error] 	at org.apache.spark.sql.catalyst.ScalaReflection$.serializerFor(ScalaReflection.scala:425)
> [error] 	at org.apache.spark.sql.catalyst.encoders.ExpressionEncoder$.apply(ExpressionEncoder.scala:71)
> [error] 	at org.apache.spark.sql.Encoders$.product(Encoders.scala:275)
> [error] 	at org.apache.spark.sql.SQLImplicits.newProductEncoder(SQLImplicits.scala:49)
> {code}
> I think the resolution to this might be similar to adding the Map type - https://github.com/apache/spark/pull/16986



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

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


Mime
View raw message