Skip to content
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

Add support for array slice #1108

Open
Weijun-H opened this issue Jan 22, 2024 · 3 comments
Open

Add support for array slice #1108

Weijun-H opened this issue Jan 22, 2024 · 3 comments

Comments

@Weijun-H
Copy link
Member

While working on apache/datafusion#8946, I discovered that sqlparser-rs does not support tokens such as [-1:-1] or [-2:3].

@alamb
Copy link
Contributor

alamb commented Jan 23, 2024

Postgres does not seem to support this either:

postgres=# select array [1,2,3][-1:1];
ERROR:  syntax error at or near "["
LINE 1: select array [1,2,3][-1:1];
                            ^
postgres=#

@Weijun-H
Copy link
Member Author

Postgres does not seem to support this either:

postgres=# select array [1,2,3][-1:1];
ERROR:  syntax error at or near "["
LINE 1: select array [1,2,3][-1:1];
                            ^
postgres=#

Yes, it supports the syntax select (array [1,2,3])[-1:1];

@alamb
Copy link
Contributor

alamb commented Jan 24, 2024

postgres=# select (array [1,2,3])[-1:1];
 array
-------
 {1}
(1 row)

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants