apache / apache/datafusion-sqlparser-rs
Misleading error message for typo in IF NOT EXISTS
- Dominant language
- Rust
- Stars
- 3.5k
- Forks
- 772
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 17
Description
See also https://github.com/GreptimeTeam/greptimedb/issues/3471.
For sqlparser-rs -
```rust
fn main() {
let sql = "CREATE TABLE IF NOT EXIST ();";
let dialect = GenericDialect {};
let ast = Parser::parse_sql(&dialect, sql).unwrap();
println!("AST: {ast:?}");
}
```
throws:
```
called `Result::unwrap()` on an `Err` value: ParserError("Expected end of statement, found: NOT at Line: 1, Column 17")
```
IIUC if we found `IF` already, the next keywords SHOULD BE `NOT EXIST` and thus the parsing logics should be `.expect_keywords`.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the provided Rust example, using GenericDialect and Parser::parse_sql on the CREATE TABLE IF NOT EXIST statement, then trace the parser path for CREATE TABLE and IF NOT EXISTS. Done means the typo produces an appropriate parser error rather than the misleading end-of-statement message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, sql
- Domain
- compilers, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100