apache / apache/datafusion-sqlparser-rs

Support Clickhouse ASSUME table constraints (and remove required parenthetical)

Đang mở
#2,466 0 bình luận 0 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ả

Hello, currently [Clickhouse's ASSUME table constraints](https://clickhouse.com/docs/reference/statements/create/table#constraints) generate parse errors:
```bash
$ cat assume_test.sql
CREATE TABLE my_table (
`date` Date,
CONSTRAINT my_constraint ASSUME (date > '2025-01-01')
)
ENGINE = MergeTree
;
```
----
```bash
$ cargo run --features json_example --example cli assume_test.sql --clickhouse
Finished [`dev` profile [unoptimized + debuginfo]](https://doc.rust-lang.org/cargo/reference/profiles.html#default-profiles) target(s) in 0.01s
Running `target/debug/examples/cli assume_test.sql --clickhouse`
Parsing from file 'assume_test.sql' using ClickHouseDialect
2026-08-31T00:27:53.248Z DEBUG [sqlparser::parser] Parsing sql 'CREATE TABLE my_table (
`date` Date,
CONSTRAINT my_constraint ASSUME (date > '2025-01-01')
)
ENGINE = MergeTree
;
'...
Error during parsing: ParserError("Expected: PRIMARY, UNIQUE, FOREIGN, CHECK, or EXCLUDE, found: ASSUME at Line: 3, Column: 30")
```

In addition, in Clickhouse table constraint expressions aren't required to have top-level parenthesis. We should support these dialect attributes for Clickhouse.

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

Bắt đầu với đường dẫn parser ClickHouseDialect được thực thi bởi lệnh `cargo run --features json_example --example cli assume_test.sql --clickhouse`. Sử dụng ví dụ SQL trong issue làm trường hợp parsing và coi công việc hoàn tất khi các ràng buộc bảng ASSUME được parse thành công cả khi có và không có dấu ngoặc đơn cấp cao nhất.

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

Đánh giá

Công nghệ
rust, sql
Lĩnh vực
databases
Loại issue
Tính năng
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
72/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.