> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ARRAY_SLICE

> Returns an inclusive slice using 1-based bounds.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

**Aliases:** [`slice`](/query/sql/functions/array/slice)

NULL supplied argument returns NULL.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
array_slice(array, start, end)
```

### Slice endpoint (scalar)

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
slice(array, start, end)
```

* The third argument is the inclusive end index. It is not a length. Supply exactly three arguments.

## 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.

### Scalar, slice endpoint

| Name | Type | Required | Description |
| - | - | - | - |
| array | ARRAY\<T> | Yes | The array. Nested elements/fields must satisfy the same element-type restrictions. |
| start | INTEGER | Yes | First selected index. |
| end | INTEGER | Yes | Last selected index. |

## Returns

* Type: ARRAY\<T>
* Possible values: Selected elements.
* NULL behavior: NULL supplied argument returns NULL.
* Shape: Contains the input elements between the inclusive start and end bounds, after adjusting out-of-range bounds as described below.
* Ordering: Preserves input encounter order; reversed positive bounds return an empty array.

### Scalar, Slice endpoint

* Type: ARRAY\<T>, preserving the input element type
* Possible values: Selected elements.
* NULL behavior: NULL supplied argument returns NULL.
* Shape: Contains the input elements between the inclusive start and end bounds, after adjusting out-of-range bounds as described below.
* Ordering: Preserves input encounter order; reversed positive bounds return an empty array.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Supports window usage | No |
| Exact result | Yes |

## Usage notes

* Negative bounds count from the end; start zero behaves as one.
* Bounds are inclusive, positive indexes are one-based, negative indexes count from the end, and start zero acts as one. Too-negative start is clamped to the start; an end beyond the length is clamped to the last element. An end below the array or a start beyond the array produces an empty array.
* 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

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT array_slice(ARRAY[1, 2, 3, 4], 2, 3) AS "value";
```

| value |
| - |
| \[2,3] |

### Alias calling form: SLICE

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT slice(ARRAY[1, 2, 3, 4], 2, 3) AS "value";
```

| value |
| - |
| \[2,3] |

## Limitations

* ARRAY\_SLICE and SLICE take exactly three arguments. The third is an inclusive end index; SLICE does not use Spark’s length interpretation. A fourth step or stride argument is not accepted.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.