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

Last update at: 2026/06/20 10:08:10