【问题标题】:Is there a null-safe comparison operator for pyspark?pyspark 是否有空安全比较运算符?
【发布时间】:2021-07-15 01:26:36
【问题描述】:

当尝试创建布尔列时,如果其他两个列相等则为 True,否则为 False,我注意到 Spark 中的 Null == Null = False。

df.withColumn('newCol', F.when(F.col('x')==F.col('y'), True).otherwise(False))

这个:https://spark.apache.org/docs/3.0.0-preview/sql-ref-null-semantics.html 建议如果我使用 SQL 语法,我可以使用 ,但如果可以的话,我希望坚持使用 pyspark sql api。

df.withColumn('newCol', F.when(F.col('x')<=>F.col('y'), True).otherwise(False))

好像没用。

有人有什么建议吗?

【问题讨论】:

标签: python apache-spark pyspark


【解决方案1】:
猜你喜欢
  • 2017-07-21
  • 1970-01-01
  • 2011-09-30
  • 2011-07-07
  • 2014-07-31
  • 2016-12-31
  • 2012-05-16
  • 2017-12-22
相关资源
最近更新 更多