หมายเหตุ
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลอง ลงชื่อเข้าใช้หรือเปลี่ยนไดเรกทอรีได้
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลองเปลี่ยนไดเรกทอรีได้
Returns null if col1 equals to col2, or col1 otherwise.
For the corresponding Databricks SQL function, see nullif function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.nullif(col1=<col1>, col2=<col2>)
Parameters
| Parameter | Type | Description |
|---|---|---|
col1 |
pyspark.sql.Column or str |
The first column to check. |
col2 |
pyspark.sql.Column or str |
The column to compare with col1. |
Examples
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(None, None,), (1, 9,)], ["a", "b"])
df.select('*', dbf.nullif(df.a, df.b)).show()
+----+----+------------+
| a| b|nullif(a, b)|
+----+----+------------+
|NULL|NULL| NULL|
| 1| 9| 1|
+----+----+------------+