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.
Collection function: Returns the length of the array or map stored in the column. Supports Spark Connect.
For the corresponding Databricks SQL function, see size function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.size(col=<col>)
Parameters
| Parameter | Type | Description |
|---|---|---|
col |
pyspark.sql.Column or str |
Name of column or expression. |
Returns
pyspark.sql.Column: length of the array/map.
Examples
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([([1, 2, 3],),([1],),([],)], ['data'])
df.select(dbf.size(df.data)).collect()
[Row(size(data)=3), Row(size(data)=1), Row(size(data)=0)]