apache / apache/datafusion-sqlparser-rs
Support Clickhouse ASSUME table constraints (and remove required parenthetical)
- Dominant language
- Rust
- Stars
- 3.5k
- Forks
- 772
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 17
Description
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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the ClickHouseDialect parser path exercised by the `cargo run --features json_example --example cli assume_test.sql --clickhouse` command. Use the SQL example in the issue as the parsing case, and consider the work done when ASSUME table constraints parse successfully both with and without top-level parentheses.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100