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
| Parameter | Type | Required | Description |
|---|---|---|---|
array | ARRAY<T> | Yes | The 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
CARDINALITYARRAY_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 BIGINT | f2 BIGINT | f3 BIGINT | f4 BIGINT | f5 BIGINT | f6 BIGINT |
|---|---|---|---|---|---|
| 5 | 3 | 5 | 4 | 1 | 0 |
On this page