好的,我有一些数据,我想过滤掉所有的空值和空值。因此,我使用简单的sql命令首先过滤掉空值。
hiveContext.sql("select username from daten where username is not null").show()我得到的是这样的东西。
org.apache.spark.sql.DataFrame = [username: array<string>]用户名
| [null]|
| [null]|
| [null]|
| []|
| []|
| [null]|
| [null]|
| []|
| [null]|
| [null]|
| [null]|
| [null]|
|[dirk.staszak.3]|
| []|
| []|
| [null]|
| [null]|
| [null]|
| [null]|
| [null]|所以仍然有一些空条目在里面。我不知道为什么?
有没有办法过滤掉这个空条目,并通过使用sparksql过滤掉所有的空字符串?我考虑过根据字符串的长度进行过滤,但是sparksql不支持len函数。
发布于 2018-08-17 03:46:31
您可以从给定表创建一个数据帧,并使用spark sql中的过滤器来完成任务dataframe.filter("username is not null and username !='null'")
https://stackoverflow.com/questions/36935424
复制相似问题