ARRAY_MAX

Returns the maximum value of the given input array.

Syntax

ARRAY_MAX(X)

Arguments

X

Type: array

An array of any comparable value type.

Returns

Type: same as input

The maximum value within X.


Examples

X
Output

[1,2,3,1,2,3]

3

[1,1,1,1,1,1,1,1]

1

[0,1,0,1,0,1]

1

[NULL,1,0,1,0,1]

NULL

[NULL]

NULL

[a,b,a,c,c,c]

c

[a,b,c,z]

z

Transformation job example

SQL

CREATE JOB function_operator_example
    ADD_MISSING_COLUMNS = true	
AS INSERT INTO default_glue_catalog.upsolver_samples.orders_transformed_data 
        MAP_COLUMNS_BY_NAME
    SELECT 
        ARRAY_MAX(ARRAY[3, 4, 0, 2, -1]) AS max_example1,
        ARRAY_MAX(ARRAY[true, false]) AS max_example2
    FROM default_glue_catalog.upsolver_samples.orders_raw_data 
    WHERE $commit_time BETWEEN run_start_time() AND run_end_time()
    GROUP BY shippinginfo_address_state
    LIMIT 1;

Query result

max_example1
max_example2

4

true

Last updated