apache / apache/datafusion-sqlparser-rs
ClickHouse: Parsing error for WITH statement using scalar expressions
- 主要言語
- Rust
- スター
- 3.5k
- フォーク
- 772
- 平均マージ
- 4日 9時間
- マージ済み PR(30日)
- 17
説明
### 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
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- clickhouse, rust, sql
- 領域
- databases
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100