New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List slicing syntax and behaviour #3176
Comments
I'm in favor of following Postgres here when possible. We should be able to support the postgres=# select i[:] from arrays;
i
------------------------
{1,2,3,4,5,6,7,8,9,10}
(1 row)
postgres=# select i[NULL:NULL] from arrays;
i
---
(1 row)
|
Feels like this is the right issue to post this: D select '12345'[3:5:1];
Error: Parser Error: syntax error at or near ":"
LINE 1: select '12345'[3:5:1]; 1 is implicit, so this would be the default already, but things like [3:5:2] would be more interesting |
I'm interested in working on this |
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
Slicing currently uses
NULL
as the unbounded marker for both list and string slicing, e.g.SELECT l[NULL:NULL] FROM (SELECT array[1, 2, 3] AS l)
.This is a workaround(?) for arr[:] (Python), which then inserts a None object. Although DuckDB also supports the syntax
SELECT l[:] FROM (SELECT array[1, 2, 3] AS l
...For Postgres compatibility
[NULL:NULL]
would have to return aNULL
.Additionally, we return
NULL
instead of an empty list (Postgres) if both indexes are less than zero and their absolute values are outside of the list length.Below are some examples.
Data creation.
DuckDB examples.
Postgres examples.
The text was updated successfully, but these errors were encountered: