过滤掉空字符串和空字符串insparksql

时间:2016-04-29 10:04:27

标签: apache-spark-sql

好的,我有一些数据,我想过滤掉所有空值和空值。所以我使用简单的sql命令来首先过滤掉空值。

function functionB(body){
    instanceModelB.instanceModelA.functionA(body)
            .then(onSuccess)
            .catch(onFail)
            .finally(onFinally);
}

我得到的是这样的。

hiveContext.sql("select username from daten where username is not null").show()

用户名

org.apache.spark.sql.DataFrame = [username: array<string>]

所以还有一些null在那里。我不知道为什么?

有没有办法过滤掉这个null entrys并使用sparksql过滤掉所有空字符串?我想过按字符串长度过滤,但sparksql不支持len函数。

1 个答案:

答案 0 :(得分:0)

您可以从给定的表中创建一个数据框,并在spark sql中使用filter来完成任务     dataframe.filter("username is not null and username !='null'")