Skip to main content
Returns a slice of an array. This function intercepts length elements from input from the position specified by offset.

Syntax

Parameters

  • input: the array whose slice you want to intercept. This function supports the following types of array elements: BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, VARCHAR, DECIMALV2, DATETIME, DATE, and JSON. JSON is supported from 2.5.
  • offset: the position from which to intercept elements. Valid values start from 1. It must be a BIGINT value.
  • length: the length of the slice that you want to intercept. It must be a BIGINT value.

Return value

Returns an array that have the same data type as the array specified by the input parameter.

Usage notes

  • The offset starts from 1.
  • If the specified length exceeds the actual number of elements that can be intercepted, all the matching elements are returned. See Example 4.

Examples

Example 1: Intercept 2 elements starting from the third element.
Example 2: Intercept 2 elements starting from the first element.
Example 3: Null elements are treated as normal values.
Example 4: Intercept 5 elements starting from the third element. This function intends to intercept 5 elements but there are only 3 elements from the third element. As a result, all of these 3 elements are returned.