Function datafusion_physical_expr::array_expressions::array_slice
source · pub fn array_slice(args: &[ArrayRef]) -> Result<ArrayRef>
Expand description
array_slice SQL function
We follow the behavior of array_slice in DuckDB
Note that array_slice is 1-indexed. And there are two additional arguments from
and to
in array_slice.
array_slice(array, from, to)
Positive index is treated as the index from the start of the array. If the
from
index is smaller than 1, it is treated as 1. If the to
index is larger than the
length of the array, it is treated as the length of the array.
Negative index is treated as the index from the end of the array. If the index
is larger than the length of the array, it is NOT VALID, either in from
or to
.
The to
index is exclusive like python slice syntax.
See test cases in array.slt
for more details.