apache / apache/datafusion-sqlparser-rs

ClickHouse: Parsing error for WITH statement using scalar expressions

Đang mở
#2,221 1 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Rust
Star
3.5k
Fork
772
Merge trung bình
4 ngày 9 giờ
Pull request đã merge (30 ngày)
17

Mô tả

### 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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
clickhouse, rust, sql
Lĩnh vực
databases
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.