Skip to main content
Version: 24.3.x

Categories: Semi-Structured Data

CARDINALITY

Returns the number of elements contained in the specified list or map.

Syntax

CARDINALITY(list_or_map list or map) → bigint

  • list_or_map: The list or map to count elements from.

Examples

CARDINALITY example
SELECT CARDINALITY(CONVERT_FROM('[1, 2, 3, 4, 5]', 'json'))
-- 5

Usage Notes

This function counts both null and non-null elements. The cardinality of null is null.