apache / apache/datafusion-sqlparser-rs

Regression: Decreased tolerance to column names matching SQL keywords

Open
#2,049 0 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

Related to: https://github.com/apache/datafusion/issues/17802

Between versions `0.57.0` and `0.58.0` there appears to be a regression that decreased parser tolerance to column names that collide with SQL keywords.

Example:
```rust
use sqlparser::dialect::GenericDialect;
use sqlparser::parser::Parser;

fn main() {
let dialect = GenericDialect {}; // or AnsiDialect

let sql = r#"
SELECT
'a' as a,
offset
FROM my_table
"#;

let ast = Parser::parse_sql(&dialect, sql).unwrap();
println!("AST: {:#?}", ast);
}
```

This works on version `0.57.0`, but fails on `0.58.0` with error:
```
ParserError("Expected: end of statement, found: my_table at Line: 5, Column: 14")
```

These queries work fine, which adds some confusing inconsistency into the mix:
```sql
SELECT
offset
FROM my_table
```
```sql
SELECT
offset,
'a' as a
FROM my_table
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the reported query with GenericDialect and AnsiDialect on versions 0.57.0 and 0.58.0, then compare the parser behavior around the offset column and FROM clause. Trace the parser entry points reached by this example and add a regression test covering the failing query; done means the query parses consistently without breaking the working variants.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.