【发布时间】:2018-04-04 14:23:06
【问题描述】:
对不起,如果这是重复的,但是,指出的解决方案对我不起作用。很可能我在这里遗漏了一些基本的东西。我有一个如下的数据框:
inputDF: org.apache.spark.sql.DataFrame = [ts: string, id: string ... 20 more fields]
我正在尝试通过执行以下操作(在 Scala 中)根据称为“状态”(字符串类型)的字段过滤此处感兴趣的一些“行”:
inputDF.filter(inputDF("state") == "BALANCED").show()
但是这给了我一个错误:
<console>:143: error: overloaded method value filter with alternatives:
(func: org.apache.spark.api.java.function.FilterFunction[org.apache.spark.sql.Row])org.apache.spark.sql.Dataset[org.apache.spark.sql.Row] <and>
(func: org.apache.spark.sql.Row => Boolean)org.apache.spark.sql.Dataset[org.apache.spark.sql.Row] <and>
(conditionExpr: String)org.apache.spark.sql.Dataset[org.apache.spark.sql.Row] <and>
(condition: org.apache.spark.sql.Column)org.apache.spark.sql.Dataset[org.apache.spark.sql.Row]
cannot be applied to (Boolean)
inputDF.filter(inputDF("connState") == "BALANCED").show()
有人可以指出这里有什么不正确的地方吗?我遵循了几个例子,包括https://rklicksolutions.wordpress.com/2016/03/03/tutorial-spark-1-6-sql-and-dataframe-operations/ 中的例子,但不知道出了什么问题。
【问题讨论】:
标签: apache-spark dataset spark-dataframe