【发布时间】:2018-09-29 15:08:28
【问题描述】:
我是 Scala 新手,很难找出这段代码的问题。
x.map{case (x1: Any, x2: Any,x3: String) => x1}.count()
投掷
scala.MatchError: null error
这是x的定义
scala> x.cache()
res111: x.type = MapPartitionsRDD[522] at map at <console>:49
scala> x
res109: org.apache.spark.rdd.RDD[(Any, Any, String)] = MapPartitionsRDD[522] at map at <console>:49
scala> x.count()
res112: Long = 64508825
任何指针将不胜感激。
【问题讨论】:
-
这意味着您的数据中有
null。为什么不只是x.map(_._1).count? -
@philantrovert 它会给空指针异常
-
@RameshMaharjan 不,不应该。
-
我刚试过 ;)
val x = sc.parallelize(Seq(("3", 1, "t"), (3.0, "1", "t"), null))这也给出了 OP 遇到的相同错误
标签: scala apache-spark rdd