arrays_zip
function
Applies to: Databricks SQL Databricks Runtime
Returns a merged array of structs in which the nth struct contains all nth values of input arrays.
Syntax
arrays_zip (array1 [, ...])
Arguments
arrayN
: An ARRAY.
Returns
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.
Examples
> SELECT arrays_zip(array(1, 2, 3), array(2, 3, 4));
[{1,2},{2,3},{3,4}]
> SELECT arrays_zip(array(1, 2), array(2, 3), array(3, 4));
[{1,2,3},{2,3,4}]
> SELECT arrays_zip(array(1, 2), array('shoe', 'string', 'budget'));
[{1, shoe},{2, string},{null,budget}]
> SELECT arrays_zip();
[{}]