Spark - 使用列名在 Dataframe 上应用 filter/map 不起作用

Spark - Applying filter/map on a Dataframe using column names not working

抱歉,如果这是重复的,但是,指出的解决方案对我不起作用。我很可能在这里遗漏了一些基本的东西。我有一个如下所示的数据框:

inputDF: org.apache.spark.sql.DataFrame = [ts: string, id: string ... 20 more fields]

我试图通过以下操作(在 Scala 中)根据名为 "state"(字符串类型)的字段过滤一些感兴趣的 "rows":

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/ 中的示例,但无法弄清楚哪里出了问题。

看来我需要使用 === 而不是 ==

inputDF.filter(inputDF("state") === "BALANCED").show()

正在做我想做的事情。