Σημείωση
Η πρόσβαση σε αυτή τη σελίδα απαιτεί εξουσιοδότηση. Μπορείτε να δοκιμάσετε να συνδεθείτε ή να αλλάξετε καταλόγους.
Η πρόσβαση σε αυτή τη σελίδα απαιτεί εξουσιοδότηση. Μπορείτε να δοκιμάσετε να αλλάξετε καταλόγους.
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)]