MAP type

Represents values comprising a set of key-value pairs.

Syntax

MAP <keyType, valueType>
  • keyType: Any data type other than MAP specifying the keys.
  • valueType: Any data type specifying the values.

Limits

The map type supports maps of any cardinality greater or equal to 0.

The keys must be unique and not be NULL.

Literals

See map function for details on how to produce literal map values.

Examples

> SELECT map('red', 1, 'green', 2);
  {red->1, green->2}
> SELECT typeof(CAST(NULL AS MAP<TIMESTAMP, INT>));
  MAP<TIMESTAMP, INT>
> SELECT map(array(1, 2), map('green', 5));
  {[1, 2]->{green->5}}
> SELECT CAST(map(struct('Hello', 'World'), 'Greeting') AS MAP<STRUCT<w1:string, w2:string>, string>);
  {{Hello, World}->Greeting}