All Products
Search
Document Center

MaxCompute:TRANSFORM

Last Updated:Sep 06, 2023

Transforms the elements in Array a by using func and returns a new array.

Syntax

array<R> transform(array<T> <a>, function<T, R> <func>)

Parameters

  • a: required. This parameter specifies an array. T in array<T> specifies the data type of the elements in the array. The elements can be of any data type.

  • func: required. This parameter specifies the built-in function, user-defined function, or expression that is used to transform the elements in Array a. The value must be of the same data type as the elements in Array a. R specifies the data type of the output results.

Return value

A value of the ARRAY type is returned.

Examples

-- The return value is [2, 3, 4]. 
select transform(array(1, 2, 3), x -> x + 1);
Note

In this example, the combination of a hyphen and a closing angle bracket (->) is used. For more information about how to use the combination of a hyphen and a closing angle bracket (->) in Lambda functions, see Lambda functions.

Related functions

TRANSFORM is a complex type function. For more information about the functions that are used to process data of complex data types, such as ARRAY, MAP, STRUCT, and JSON, see Complex type functions.