size function (Databricks SQL)

Returns the cardinality of the array or map in expr.

Syntax

size(expr)

Arguments

  • expr: An ARRAY or MAP expression.

Returns

An INTEGER.

Examples

> SELECT size(array('b', 'd', 'c', 'a'));
 4
> SELECT size(map('a', 1, 'b', 2));
 2
> SELECT size(NULL);
 -1