หมายเหตุ
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลอง ลงชื่อเข้าใช้หรือเปลี่ยนไดเรกทอรีได้
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลองเปลี่ยนไดเรกทอรีได้
Applies to:
Databricks SQL
Databricks Runtime
Returns a subset of an array.
Syntax
slice(expr, start, length)
Arguments
expr: AnARRAYexpression.start: AnINTEGERexpression.length: AnINTEGERexpression that is greater or equal to 0.
Returns
The result is of the type of expr.
The function subsets array expr starting from index start (array indices start at 1), or starting from the end if start is negative, with the specified length.
If the requested array slice does not overlap with the actual length of the array, an empty array is returned.
Examples
> SELECT slice(array(1, 2, 3, 4), 2, 2);
[2,3]
> SELECT slice(array(1, 2, 3, 4), -2, 2);
[3,4]