apache / apache/datafusion-sqlparser-rs

Support Clickhouse ASSUME table constraints (and remove required parenthetical)

未关闭
#2,466 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Rust
星标
3.5k
派生
772
平均合并
4 天 9 小时
30 天内合并 PR
17

描述

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.

贡献指南

这个仓库没有索引到贡献指南

调研方向

从由 `cargo run --features json_example --example cli assume_test.sql --clickhouse` 命令执行的 ClickHouseDialect 解析器路径开始。使用 issue 中的 SQL 示例作为解析案例,并在 ASSUME 表约束在有和没有顶层括号的情况下都能成功解析时,视为工作完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
rust, sql
领域
databases
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
活跃
描述清晰度
基本清楚
新手友好度
72/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。