Array Slicing issue

We are doing pagination using array slicing issue and we have issues when we are on last page and if the number of records do not match the page size. We are doing something similar to this:

select [1, 2, 3, 4, 5][3:7] as res;

This gives empty result even though it should return two items. Any way to get this done ?

We don’t know the page size and record count when we are doing the query

You are exceeded the slice limit

You can do following

SELECT a[3:LEAST(7,ARRAY_LENGTH(a))] AS res LET a = [1, 2, 3, 4, 5];
SELECT a[3:] AS res LET a = [1, 2, 3, 4, 5];

1 Like