SLICE

Syntax

SLICE( array, offset, length )

Description

Returns the part of array array of length length starting from index offset. Indexes in an array begin with one.

Argument types:

  • arrayArray of fractional numbers | Array of integers | Array of strings
  • offsetInteger
  • lengthInteger

Return type: Same type as (array)

Note

Only constant values are accepted for the arguments (offset, length).

Examples

SLICE(ARRAY(1, 2, 3, 4, 5), 3, 2) = [3, 4]
SLICE(ARRAY(1, 2, 3, 4, 5), 3, 1) = [3]

Data source support

ClickHouse 21.8, PostgreSQL 9.3.

Previous