我正面临这个错误,flatMap
但不是map
。转换不支持布尔运算flatMap
吗?
scala> val array = Array("age","astro")
array: Array[String] = Array(age, astro)
scala> val baseRdd = sc.parallelize(array)
baseRdd: org.apache.spark.rdd.RDD[String] = ParallelCollectionRDD[0] at parallelize at <console>:29
scala> val flat2 = baseRdd2.flatMap(x => x.contains("a"))
<console>:31: error: type mismatch;
found : Boolean
required: TraversableOnce[?]
val flat2 = baseRdd2.flatMap(x => x.contains("a"))