apache / apache/datafusion-sqlparser-rs
Cannot parse table alias or cte alias in Postgres dialect
- Lingua principale
- Rust
- Stelle
- 3.5k
- Fork
- 772
- Merge medio
- 4g 9h
- PR unite (30g)
- 17
Descrizione
Sorry for bothering you.
I'm using sqlparser = "0.40.0"
This is my code:
```rust
use sqlparser::dialect::PostgreSqlDialect;
use sqlparser::parser::{Parser, ParserError};
fn main() {
let dialect = PostgreSqlDialect {};
let sql1 = r#"
WITH existing AS (SELECT test_table.id FROM test_tables AS test_table WHERE (a = 12) AND (b = 34)),
inserted AS (INSERT INTO test_tables AS test_table (id, a, b, c) VALUES (DEFAULT, 56, 78, 90) ON CONFLICT (a, b)
DO UPDATE SET c = EXCLUDED.c WHERE (test_table.c != EXCLUDED.c)) SELECT c FROM existing"#;
let sql2 = "INSERT INTO test_tables AS test_table (id, a) VALUES (DEFAULT, 123) ON CONFLICT DO NOTHING RETURNING id";
let ast1 = Parser::parse_sql(&dialect, sql1);
match ast1 {
Ok(_) => {
}
Err(e) => {
println!("fail ast1: {}", e);
}
}
let ast2 = Parser::parse_sql(&dialect, sql2);
match ast2 {
Ok(_) => {
}
Err(e) => {
println!("fail ast2: {}", e);
}
}
}
```
error output:
```bash
fail ast1: sql parser error: Expected SELECT, VALUES, or a subquery in the query body, found: AS at Line: 3, Column 43
fail ast2: sql parser error: Expected SELECT, VALUES, or a subquery in the query body, found: AS at Line: 1, Column 25
```
Thank you!
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Inizia con le chiamate a PostgreSqlDialect e Parser::parse_sql nel riproduttore, eseguendo sia sql1 sia sql2 per confermare gli errori di analisi degli alias. Traccia come le istruzioni INSERT e i corpi delle query CTE gestiscono gli alias; il lavoro è completato quando entrambe le istruzioni PostgreSQL vengono analizzate correttamente senza gli errori segnalati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- postgresql, rust
- Ambito
- databases
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100