Skip to main content
Merges the given arrays by index into an array of structs in which the n-th struct contains n-th values of all input arrays. When array lengths differ, missing elements are filled with NULL.

Syntax

Parameters

  • array_n: Arrays to be merged. Each array can contain elements of any supported type.

Return value

Returns an ARRAY of STRUCT, where the n-th struct contains the n-th field of each input array. If input arrays have different lengths, shorter arrays are padded with NULL values.

Usage notes

  • If the input arrays have different lengths, the result array length is the maximum length among input arrays.
  • Missing values in shorter arrays are filled with NULL.
  • If any input array is NULL, the result is NULL.
  • If all input arrays are empty, the result is an empty array.

Examples

Example 1: Merge two arrays with equal length.
Example 2: Merge two arrays with different lengths.
Example 3: Merge three arrays.
Example 4: Merge two empty arrays.
Example 5: Merge a single array.
Example 6: Merge arrays when one of them is NULL.
Example 7: Merge arrays of mixed types with NULL values.
Example 8: Merge arrays from table data.