Skip to content
Snippets Groups Projects
Commit aa41a522 authored by baishuo(白硕)'s avatar baishuo(白硕) Committed by Michael Armbrust
Browse files

fix java.lang.ClassCastException

get Exception when run:bin/run-example org.apache.spark.examples.sql.RDDRelation
Exception's detail is:
Exception in thread "main" java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
	at scala.runtime.BoxesRunTime.unboxToInt(BoxesRunTime.java:106)
	at org.apache.spark.sql.catalyst.expressions.GenericRow.getInt(Row.scala:145)
	at org.apache.spark.examples.sql.RDDRelation$.main(RDDRelation.scala:49)
	at org.apache.spark.examples.sql.RDDRelation.main(RDDRelation.scala)
change sql("SELECT COUNT(*) FROM records").collect().head.getInt(0) to sql("SELECT COUNT(*) FROM records").collect().head.getLong(0), then the Exception do not occur any more

Author: baishuo(白硕) <vc_java@hotmail.com>

Closes #949 from baishuo/master and squashes the following commits:

f4b319f [baishuo(白硕)] fix java.lang.ClassCastException
parent 8edc9d03
No related branches found
No related tags found
No related merge requests found
...@@ -43,7 +43,7 @@ object RDDRelation { ...@@ -43,7 +43,7 @@ object RDDRelation {
sql("SELECT * FROM records").collect().foreach(println) sql("SELECT * FROM records").collect().foreach(println)
// Aggregation queries are also supported. // Aggregation queries are also supported.
val count = sql("SELECT COUNT(*) FROM records").collect().head.getInt(0) val count = sql("SELECT COUNT(*) FROM records").collect().head.getLong(0)
println(s"COUNT(*): $count") println(s"COUNT(*): $count")
// The results of SQL queries are themselves RDDs and support all normal RDD functions. The // The results of SQL queries are themselves RDDs and support all normal RDD functions. The
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment