ZIP

ZIP combines multiple unrelated arrays, by index, into a single array as array elements. Array element names should be specified as a static input. For better understanding of array handling, please review the Work with Arrays page.

Syntax

ZIP('element1,...,elenentN', array1[], ..., arrayN[])

Arguments

element1,...

A comma separated list of elements in the output array. The number of elements should match the number of arrays in the parameters that follow. The element list should be enclosed in single quotes.

array1[],...

Comma separated list of single element arrays to be zipped into a single multi-element array.

Returns

Single Array constructed of the elements in the input array(s).

Example

Data:

{
   "area_code":[
      "616",
      "857"
   ],
   "phone_number":[
      "342-7763",
      "777-0984"
   ]
}

Query:

// code the zip function in a SET statement for a better readability
SET full_phone_number = ZIP('area_code,phone_number', area_code[], phone_number[]);
//
SELECT full_phone_number[].area_code, 
       full_phone_number[].phone_number
FROM "customer_record"

Results:

{
   "full_phone_number":[
      {
         "area_code":"616",
         "phone_number":"342-7763"
      },
      {
         "area_code":"857",
         "phone_number":"777-0984"
      }
   ]
}

Last updated