Skip to content

Commit aa41a52

Browse files
baishuomarmbrus
authored andcommitted
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(白硕) <[email protected]> Closes #949 from baishuo/master and squashes the following commits: f4b319f [baishuo(白硕)] fix java.lang.ClassCastException
1 parent 8edc9d0 commit aa41a52

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

examples/src/main/scala/org/apache/spark/examples/sql/RDDRelation.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ object RDDRelation {
4343
sql("SELECT * FROM records").collect().foreach(println)
4444

4545
// Aggregation queries are also supported.
46-
val count = sql("SELECT COUNT(*) FROM records").collect().head.getInt(0)
46+
val count = sql("SELECT COUNT(*) FROM records").collect().head.getLong(0)
4747
println(s"COUNT(*): $count")
4848

4949
// The results of SQL queries are themselves RDDs and support all normal RDD functions. The

0 commit comments

Comments
 (0)