如何在不使用SQL查询的情况下使用Spark Dataframe检查是否相等?

问题描述:

我想选择一个等于某个值的列.我在Scala中这样做,遇到了一些麻烦.

I want to select a column that equals to a certain value. I am doing this in scala and having a little trouble.

在这里输入我的代码

df.select(df("state")==="TX").show()

这将返回带有布尔值的state列,而不仅仅是TX

this returns the state column with boolean values instead of just TX

我也尝试过

df.select(df("state")=="TX").show() 

但这也不起作用.

我遇到了同样的问题,以下语法对我有用:

I had the same issue, and the following syntax worked for me:

df.filter(df("state")==="TX").show()

我正在使用Spark 1.6.

I'm using Spark 1.6.