All Products
Search
Document Center

MaxCompute:ARRAY_REMOVE

Last Updated:Mar 26, 2026

Removes a given element from Array a. For example, array_remove(array(3, 2, 1), 1) returns [3, 2].

Syntax

array<T> array_remove(array<T> <a>, T <element>)

Parameters

  • a: Required. The source array. T in array<T> is the element data type. Supported types:

    • TINYINT, SMALLINT, INT, BIGINT

    • FLOAT, DOUBLE

    • BOOLEAN

    • DECIMAL, DECIMALVAL

    • DATE, DATETIME, TIMESTAMP, IntervalDayTime, IntervalYearMonth

    • STRING, BINARY, VARCHAR, CHAR

    • ARRAY, STRUCT, MAP

  • element: Required. The value to remove. The data type must match that of the elements in a.

Return value

Returns an ARRAY value.

Usage notes

  • If a or element is null, the function returns null.

  • Null elements in a are skipped during comparison and preserved in the output.

  • If a does not contain element, the function returns a unchanged.

Examples

The following examples cover standard removal, a null element argument, and an element not present in the array.

-- Remove 1 from array(3, 2, 1). Returns [3,2].
select array_remove(array(3, 2, 1), 1);

-- Pass null as the element to remove. Returns null.
select array_remove(array(3, 1, null), null);

-- Remove 2 from array(3, 1, null), where 2 is not present. Returns [3,1,null].
select array_remove(array(3, 1, null), 2);

Related functions

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