Skip to main content
Scalar function
Returns NULL for a NULL array. A NULL element is inserted as a NULL array element.

Syntax

Scalar

Arguments

Type notation used below:
  • T is the array element type: BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE, DECIMAL(p, s), STRING, BINARY, DATE, TIME, TIMESTAMP, ARRAY, MAP or STRUCT.

Returns

  • Type: ARRAY<T>
  • Possible values: The input elements plus the added element.
  • NULL behavior: Returns NULL for a NULL array. A NULL element is inserted as a NULL array element.
  • Shape: The original length plus one.
  • Ordering: Original array order with the added element at the start.

Properties

Usage notes

  • Pass the array first and the element second. An untyped NULL takes the array’s element type. An array of untyped NULLs takes the supplied element’s type.
  • INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.

Examples

Typical behavior

Prepend a string

Limitations

  • The element and the array’s elements must have compatible types. Use explicit casts for mixed numeric types.
Last modified on October 15, 2026