Skip to main content

MAP_SIZE

Description

Calculates the number of elements in a Map

Syntax

MAP_SIZE(<map>)

Parameters

  • <map> MAP type, the input map content.

Return Value

Returns the number of elements in the Map

Usage Notes

  1. Both NULL keys and values are counted.
  2. For NULL parameters, returns NULL.

Examples

  1. Regular parameters

    select map_size(map()), map_size(map(1, "100", 0.1, 2, null, null));
    +-----------------+---------------------------------------------+
    | map_size(map()) | map_size(map(1, "100", 0.1, 2, null, null)) |
    +-----------------+---------------------------------------------+
    | 0 | 3 |
    +-----------------+---------------------------------------------+
  2. NULL parameters

    select map_size(NULL);
    +----------------+
    | map_size(NULL) |
    +----------------+
    | NULL |
    +----------------+