Subscript in sqlparser::ast - Rust

pub enum Subscript {
    Index {
        index: Expr,
    },
    Slice {
        lower_bound: Option<Expr>,
        upper_bound: Option<Expr>,
        stride: Option<Expr>,
    },
}
Expand description

The contents inside the [ and ] in a subscript expression.

§

Accesses the element of the array at the given index.

Fields

The index expression used to access the array element.

§

Accesses a slice of an array on PostgreSQL, e.g.

=> select (array[1,2,3,4,5,6])[2:5];
-----------
{2,3,4,5}

The lower and/or upper bound can be omitted to slice from the start or end of the array respectively.

See https://www.postgresql.org/docs/current/arrays.html#ARRAYS-ACCESSING.

Also supports an optional “stride” as the last element (this is not supported by postgres), e.g.

=> select (array[1,2,3,4,5,6])[1:6:2];
-----------
{1,3,5}

Fields

Optional lower bound for the slice (inclusive).

Optional upper bound for the slice (inclusive).

Optional stride for the slice (step size).

§
§
§
§
§
§