You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "bluejoe (JIRA)" <ji...@apache.org> on 2017/09/04 08:21:00 UTC

[jira] [Created] (SPARK-21905) ClassCastException when call sqlContext.sql on temp table

bluejoe created SPARK-21905:
-------------------------------

             Summary: ClassCastException when call sqlContext.sql on temp table
                 Key: SPARK-21905
                 URL: https://issues.apache.org/jira/browse/SPARK-21905
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 2.2.0
            Reporter: bluejoe



{code:java}
		val schema = StructType(List(
			StructField("name", DataTypes.StringType, true),
			StructField("location", new PointUDT, true)))

		val rowRdd = sqlContext.sparkContext.parallelize(Seq("bluejoe", "alex"), 4).map({ x: String ⇒ Row.fromSeq(Seq(x, Point(100, 100))) });
		val dataFrame = sqlContext.createDataFrame(rowRdd, schema)
		dataFrame.createOrReplaceTempView("person");
		sqlContext.sql("SELECT * FROM person").foreach(println(_));
{code}

the last statement throws exception:


{code:java}
Caused by: java.lang.ClassCastException: org.apache.spark.sql.catalyst.expressions.GenericRow cannot be cast to org.apache.spark.sql.catalyst.InternalRow
	at org.apache.spark.sql.catalyst.expressions.GeneratedClass$SpecificUnsafeProjection.evalIfFalseExpr1$(Unknown Source)
	at org.apache.spark.sql.catalyst.expressions.GeneratedClass$SpecificUnsafeProjection.apply(Unknown Source)
	at org.apache.spark.sql.catalyst.encoders.ExpressionEncoder.toRow(ExpressionEncoder.scala:287)
	... 18 more
{code}





--
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