apache / apache/datafusion-sqlparser-rs

SQL is parsed incorrectly when `trailing_commas` is not set

Open
#1,064 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
3.5k
Forks
772
Avg merge
4d 9h
Merged PRs (30d)
17

Description

When parser not set `trailing_commas=true` in `ParserOptions` or use `BigQueryDialect`, the following SQL will be wrongly parse instead of throw an error.

```sql
SELECT foo, bar, FROM baz

-- Will be wrongly parse instead of throw an error.

SELECT foo, bar, FROM AS baz
```

In theory it should throw a error

relevant code

```rust
#[test]
fn parse_range_select() {
let statements = Parser::parse_sql(&GenericDialect {}, "SELECT foo, bar, FROM baz").unwrap();
println!("{}", statements[0]);
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Parser::parse_sql call in the parse_range_select example and inspect how GenericDialect handles SELECT lists when trailing_commas is unset. Add a regression test covering the shown queries, with malformed trailing-comma syntax rejected while the configured trailing_commas behavior remains supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.