【发布时间】:2018-07-10 15:49:54
【问题描述】:
以下是示例代码,仅当我将这两段代码放在 spark shell 中时才会发生。它也只发生在 spark 1.6 和 scala 2.10 上。我想这是scala 2.10的问题。有谁知道根本原因。谢谢
case class Bank(
age: Integer,
job: String,
marital: String,
education: String,
balance: Integer
)
val bank =
bankText.
map(s => s.split(";")).
filter(s => s(0) != "\"age\"").
map(
s =>
Bank(
s(0).toInt,
s(1).replaceAll("\"", ""),
s(2).replaceAll("\"", ""),
s(3).replaceAll("\"", ""),
s(5).replaceAll("\"", "").toInt
)
).toDF()
错误:
error: value toDF is not a member of org.apache.spark.rdd.RDD[Bank]
possible cause: maybe a semicolon is missing before `value toDF'?
).toDF()
^
【问题讨论】:
-
你分享的sn-p不包括,但我想你已经导入了
spark.implicits._,对吧? -
是的,是spark-shell导入的
标签: scala apache-spark