arrays_zip function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

Returns a merged array of structs in which the nth struct contains all nth values of input arrays.


arrays_zip (array1 [, ...])


  • arrayN: An ARRAY.


An ARRAY of STRUCT where the type of the nth field that matches the type of the elements of arrayN.

The number of array arguments can be 0 or more. If the function is called without arguments it returns an empty array of an empty struct. Arrays that are shorter than the largest array are extended with null elements.


> SELECT arrays_zip(array(1, 2, 3), array(2, 3, 4));
> SELECT arrays_zip(array(1, 2), array(2, 3), array(3, 4));
> SELECT arrays_zip(array(1, 2), array('shoe', 'string', 'budget'));
 [{1, shoe},{2, string},{null,budget}]
> SELECT arrays_zip();