apache / apache/datafusion

support list slicing with negative index

Open
#9,036 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### Is your feature request related to a problem or challenge?

> > sqlparser-rs does not support these syntax.
> > ```
> > ❯ select [1,2,3][-1:-3:-2]; 🤔 Invalid statement: sql parser error: Expected a value, found: -
> > ❯ select [1,2,3][-1:-3]; 🤔 Invalid statement: sql parser error: Expected a value, found: -
> > ```
>
> This is not valid in duckdb too, try `select ([1,2,3])[-1:-3]`

This Is the problem of `sqlparser-rs`, https://github.com/sqlparser-rs/sqlparser-rs/issues/1108.

_Originally posted by @Weijun-H in https://github.com/apache/arrow-datafusion/issues/8946#issuecomment-1909633733_

### Describe the solution you'd like

_No response_

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the two SQL examples in the issue and read sqlparser-rs issue 1108, which is identified as the related parser problem. Done means the negative-index slicing syntax is accepted rather than failing on the minus sign; the issue does not name a DataFusion file or test.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.