ARRAY type

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

Represents values comprising a sequence of elements with the type of elementType.

Syntax

ARRAY < elementType >
  • elementType: Any data type defining the type of the elements of the array.

Limits

The array type supports sequences of any length greater or equal to 0.

Literals

See array function for details on how to produce literal array values.

See [ ] operator for details how to retrieve elements from an array.

Examples

> SELECT ARRAY(1, 2, 3);
  [1, 2, 3]

> SELECT CAST(ARRAY(1, 2, 3) AS ARRAY<TINYINT>);
  [1, 2, 3]

> SELECT typeof(ARRAY());
  ARRAY<NULL>

> SELECT CAST(ARRAY(ARRAY(1, 2), ARRAY(3, 4)) AS ARRAY<ARRAY<BIGINT>>);
  [[1, 2], [3, 4]]

> SELECT a[1] FROM VALUES(ARRAY(3, 4)) AS T(a);
  4