ARRAY_COUNT()

All functions > ARRAY > ARRAY_COUNT()

Returns the number of elements in an array.

Signatures

Returns: The number of elements in the array

ARRAY_COUNT(array: ARRAY<T>) → BIGINT
sql
ParameterTypeRequiredDescription
arrayARRAY<T>YesThe input array to count elements from

Notes

  • Counts all elements including duplicates and NULL values
  • Returns 0 for empty arrays
  • Also available as CARDINALITY alias
  • Useful for data validation and conditional logic

Aliases

  • CARDINALITY

  • ARRAY_LENGTH

See also

Examples

FeatureQL
SELECT
    f1 := CARDINALITY(ARRAY[1, 2, 3, 4, 5]), -- Count basic array elements
    f2 := CARDINALITY(ARRAY['A', 'B', 'C']), -- Count string array elements
    f3 := CARDINALITY(ARRAY[1, 1, 2, 2, 3]), -- Count includes duplicates
    f4 := CARDINALITY(ARRAY[1, NULL::BIGINT, 2, NULL::BIGINT]), -- Count includes NULL values
    f5 := CARDINALITY(ARRAY[42]), -- Single element array
    f6 := CARDINALITY(ARRAY[]::BIGINT[]) -- Empty array
;
Result
f1 BIGINTf2 BIGINTf3 BIGINTf4 BIGINTf5 BIGINTf6 BIGINT
535410

Last update at: 2026/05/26 17:22:09