apache / apache/datafusion-sqlparser-rs

Parse errors should show location of error in input sql string

Open
#301 1 comment 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 rust compiler finds a problem, it shows me exactly where to look:
```
error[E0308]: mismatched types
--> src/main.rs:73:12
|
72 | fn foo() -> String {
| ------ expected `std::string::String` because of return type
73 | return 42;
| ^^
| |
| expected struct `std::string::String`, found integer
| help: try using a conversion method: `42.to_string()`
```

When `Parser::parse_sql(...)` fails, it does not tell the user what part of the input caused the error:
```
sql parser error: Expected end of statement, found: ENGINE
```

The error should provide a position in the input sql string. Bonus points if it has nice presentation like the rust compiler error messages.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the Parser::parse_sql(...) entry point and trace how parse failures are constructed, using the reported ENGINE example to identify the input location that should be exposed. Done means parse errors identify the offending position in the SQL string; Rust-style presentation is an optional enhancement.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
compilers
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.