apache / apache/datafusion-sqlparser-rs
`Parser::parse_query` doesn't detect wildcard syntax errors
- Lingua principale
- Rust
- Stelle
- 3.5k
- Fork
- 772
- Merge medio
- 4g 9h
- PR unite (30g)
- 17
Descrizione
For some reason `Parser::parse_query` thinks the following are valid queries (whereas `Parser::parse_sql` correctly detects them as syntax errors):
```
SELECT * as foo FROM bar;
SELECT * foo FROM bar;
SELECT * 5 FROM bar;
```
Code to reproduce:
```rust
use sqlparser::{dialect::AnsiDialect, parser::Parser, tokenizer::Tokenizer};
fn main() {
let dialect = AnsiDialect {};
let bogus_query = "SELECT * as foo";
// Parser::parse_sql fails as expected with:
// ParserError("Expected end of statement, found: as")
assert!(Parser::parse_sql(&dialect, bogus_query).is_err());
// Parser::parse_query however does not detect the syntax error
let tokens = Tokenizer::new(&dialect, bogus_query).tokenize().unwrap();
let mut parser = Parser::new(tokens, &dialect);
assert!(parser.parse_query().is_ok());
}
```
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Start at Parser::parse_query and compare its behavior with Parser::parse_sql using the supplied Rust reproduction and Tokenizer setup. Trace how the three malformed SELECT queries are handled, then add regression coverage so parse_query rejects each wildcard syntax error while valid queries continue to parse.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- rust
- Ambito
- compilers, databases
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 68/100