shuffle function (Databricks SQL)

Returns a random permutation of the array in expr.

Syntax

shuffle(expr)

Arguments

  • expr: An ARRAY expression.

Returns

The result type matches the type expr.

This function is non-deterministic.

Examples

> SELECT shuffle(array(1, 20, 3, 5));
 [3,1,5,20]
> SELECT shuffle(array(1, 20, NULL, 3));
 [20,NULL,3,1]