<lambda>: A lambda expression that defines the transformation. The number of parameters in the lambda must match the number of input arrays.
Optional
<array2>, ...: Additional input arrays. When multiple arrays are provided, the lambda receives corresponding elements from each array. All arrays must have the same length.
Returns
Returns an array with the same length as the input arrays, where each element is the result of applying the lambda expression to the corresponding input element(s). Returns NULL if any input array is NULL.
Considerations
All input arrays must have the same length. Mismatched lengths result in an error.
NULL elements in the input arrays propagate through the lambda. If any input element is NULL, the corresponding output element is typically NULL (depending on the lambda expression).
The lambda’s return type determines the output array’s element type. If the lambda returns only NULL, you must explicitly cast it to a specific type.
Empty arrays return an empty array.
Examples
Transform a Single Array
Double each element in an array.
1SELECT ARRAY_TRANSFORM(ARRAY[1, 2, 3], lambda x: x * 2)AS doubled;