Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Returns col2 if col1 is null, or col1 otherwise.
For the corresponding Databricks SQL function, see ifnull function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.ifnull(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 value to return if col1 is null. |
Examples
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(None,), (1,)], ["e"])
df.select(dbf.ifnull(df.e, dbf.lit(8))).show()
+------------+
|ifnull(e, 8)|
+------------+
| 8|
| 1|
+------------+