MAP_FROM_ARRAYS

Overview

Constructs a MAP type using two arrays as keys and values respectively. The two arrays must have strictly equal lengths.

Syntax

MAP_FROM_ARRAYS(<keys>, <values>)

Parameters

  • <keys>: ARRAY<K> type, the array of keys.
  • <values>: ARRAY<V> type, the array of values. Must have the same length as <keys>; values may be NULL. If either argument is NULL, the result is NULL.

Examples

SELECT map_from_arrays(array(1, 2, 3), array('a', 'b', 'c')); -- {"1":"a","2":"b","3":"c"} SELECT map_from_arrays(array(1, 2, 3), array('a', NULL, 'c')); -- {"1":"a","2":null,"3":"c"} SELECT map_from_arrays(NULL, array('a', 'b', 'c')); -- NULL SELECT map_from_arrays(array(1, 2, 3), NULL); -- NULL