apache / apache/datafusion-sqlparser-rs
ClickHouse: Parsing error for WITH statement using scalar expressions
- 主要语言
- Rust
- 星标
- 3.5k
- 派生
- 772
- 平均合并
- 4 天 9 小时
- 30 天内合并 PR
- 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