reverse function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

Returns a reversed string or an array with reverse order of elements.

Syntax

reverse(expr)

Arguments

  • expr: A STRING or ARRAY expression.

Returns

The result type matches the type of expr.

Examples

> SELECT reverse('Spark SQL');
 LQS krapS
> SELECT reverse(array(2, 1, 4, 3));
 [3,4,1,2]