Poznámka
Na prístup k tejto stránke sa vyžaduje oprávnenie. Môžete sa skúsiť prihlásiť alebo zmeniť adresáre.
Na prístup k tejto stránke sa vyžaduje oprávnenie. Môžete skúsiť zmeniť adresáre.
Returns the number of elements in the outermost JSON array. NULL is returned in case of any other valid JSON string, NULL or an invalid JSON.
Syntax
from pyspark.sql import functions as sf
sf.json_array_length(col)
Parameters
| Parameter | Type | Description |
|---|---|---|
col |
pyspark.sql.Column or str |
Target column to compute on. |
Returns
pyspark.sql.Column: length of json array.
Examples
from pyspark.sql import functions as sf
df = spark.createDataFrame([(None,), ('[1, 2, 3]',), ('[]',)], ['data'])
df.select(sf.json_array_length(df.data).alias('r')).collect()
[Row(r=None), Row(r=3), Row(r=0)]