All Products
Search
Document Center

MaxCompute:SHUFFLE

Last Updated:Jul 24, 2023

Returns elements of an array in random order.

Syntax

	shuffle(array)

Parameters

array: an input array.

Return value

Elements of an array in random order are returned.

  • If the input value is null, null is returned.

  • The returned result of this function is undefined.

Examples

  • SELECT shuffle(array(1, 20, 3, 5));

    The following result is returned:

    [3,1,5,20]	
  • SELECT shuffle(array(1, 20, null, 3));

    The following result is returned:

    [20,null,3,1]

Related functions

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