Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
Databricks SQL
Databricks Runtime
Returns the cardinality of the array or map in expr.
Syntax
size(expr)
Arguments
expr: AnARRAYorMAPexpression.
Returns
An INTEGER.
Note
In Databricks Runtime, if spark.sql.ansi.enabled is false, size(NULL) returns -1 instead of NULL.
Examples
> SELECT size(array('b', 'd', 'c', 'a'));
4
> SELECT size(map('a', 1, 'b', 2));
2
> SELECT size(NULL);
-1