ARRAY_TRANSFORM

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Applies a lambda expression to each element (or corresponding elements from multiple arrays) and returns a new array with the transformed values.

  • <array1>: The first input array.
  • <lambda>: A lambda expression that defines the transformation. The number of parameters in the lambda must match the number of input arrays.
  • <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 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.

  • 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.

Double each element in an array.

Returns [2, 4, 6].

Add corresponding elements from two arrays.

Returns [11, 22, 33].

Concatenate corresponding strings from two arrays.

Returns ["hello world", "good bye"].

Use CASE to apply conditional logic.

Returns [4, 5, 6].

Compare corresponding elements and return boolean results.

Returns [false, true, false].

Combine elements from three arrays.

Returns [9, 12].

NULL elements propagate through the transformation.

Returns [5, NULL, 9].

Use nested calls to chain transformations.

Returns [40, 120].