spark-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anbu Cheeralan (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (SPARK-15507) ClassCastException: SomeCaseClass cannot be cast to org.apache.spark.sql.Row
Date Thu, 03 Nov 2016 04:38:58 GMT

    [ https://issues.apache.org/jira/browse/SPARK-15507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15631543#comment-15631543
] 

Anbu Cheeralan edited comment on SPARK-15507 at 11/3/16 4:38 AM:
-----------------------------------------------------------------

This also creates issues in float to Double conversion as well.
Error:
Caused by: java.lang.RuntimeException: java.lang.Float is not a valid external type for schema
of double

{code}
    val schema = StructType(Seq(
      StructField("a", DoubleType, true)
    ))
    val rdd = spark.sparkContext.parallelize(Seq(Row(1.1f)))

    val df = spark.createDataFrame(rdd, schema)
    df.show
{code}


was (Author: alunarbeach):
This also creates issues in float to Double conversion as well.
{code}
    val schema = StructType(Seq(
      StructField("a", DoubleType, true)
    ))
    val rdd = spark.sparkContext.parallelize(Seq(Row(1.1f)))

    val df = spark.createDataFrame(rdd, schema)
    df.show
{code}

> ClassCastException: SomeCaseClass cannot be cast to org.apache.spark.sql.Row
> ----------------------------------------------------------------------------
>
>                 Key: SPARK-15507
>                 URL: https://issues.apache.org/jira/browse/SPARK-15507
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>         Environment: spark 2.0.0-SNAPSHOT may 24
>            Reporter: koert kuipers
>
> given this code:
> {noformat}
> case class Test(a: Int, b: String)
> val rdd = sc.parallelize(List(Row(List(Test(5, "ha"), Test(6, "ba")))))
> val schema = StructType(Seq(
>   StructField("x", ArrayType(
>     StructType(Seq(
>       StructField("a", IntegerType, false),
>       StructField("b", StringType, true)
>     )),
>     true)
>   , true)
>   ))
> val df = sqlc.createDataFrame(rdd, schema)
> df.show
> {noformat}
> this works fine in spark 1.6.1 and gives:
> {noformat}
> +----------------+
> |               x|
> +----------------+
> |[[5,ha], [6,ba]]|
> +----------------+
> {noformat}
> but in spark 2.0.0-SNAPSHOT i get:
> {noformat}
> org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 0.0
failed 1 times, most recent failure: Lost task 0.0 in stage 0.0 (TID 0, localhost): java.lang.RuntimeException:
Error while encoding: java.lang.ClassCastException: Test cannot be cast to org.apache.spark.sql.Row
> [info] getexternalrowfield(input[0, org.apache.spark.sql.Row, false], 0, x, IntegerType)
AS x#0
> [info] +- getexternalrowfield(input[0, org.apache.spark.sql.Row, false], 0, x, IntegerType)
> [info]    +- input[0, org.apache.spark.sql.Row, false]
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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


Mime
View raw message