apache / apache/datafusion-sqlparser-rs
ClickHouse: Parsing error for WITH statement using scalar expressions
- Lingua principale
- Rust
- Stelle
- 3.5k
- Fork
- 772
- Merge medio
- 4g 9h
- PR unite (30g)
- 17
Descrizione
### Describe the bug
The ClickHouseDialect parser fails to parse valid ClickHouse syntax when WITH clause is used declaring [scalar expressions](https://clickhouse.com/docs/sql-reference/statements/select/with#common-scalar-expressions).
### To Reproduce
```
use sqlparser::dialect::ClickHouseDialect;
use sqlparser::parser::Parser;
fn main() {
let sql = r#"
WITH 42 AS answer
SELECT answer FROM table
"#;
let dialect = ClickHouseDialect {};
let result = Parser::parse_sql(&dialect, sql);
println!("{:?}", result);
}
```
**Error:**
Err(ParserError("Expected: identifier, found: 42 at Line: 2, Column: 14"))
### Expected behavior tested in ClickHouse 26.1.2.11
The parser using ClickHouseDialect should accept the clause as ClickHouse does support it:
`WITH 42 AS answer SELECT answer FROM table`
### Additional context
The syntax from the [ClickHouse documentation](https://clickhouse.com/docs/sql-reference/statements/select/with#common-scalar-expressions-syntax) for this clause is: `WITH AS `
sqlparser version: 0.61
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Start with ClickHouseDialect and reproduce the supplied Parser::parse_sql example for `WITH 42 AS answer SELECT answer FROM table`. Trace how the ClickHouse WITH clause is parsed, then verify that the parser accepts scalar expressions followed by an alias without regressing existing WITH handling.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- clickhouse, rust, sql
- Ambito
- databases
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100