apache / apache/datafusion-sqlparser-rs

ClickHouse dialect should not require interval qualifier

Open Beginner friendly
#2,390 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
3.5k
Forks
772
Avg merge
4d 9h
Merged PRs (30d)
17

Description

When the `require_interval_qualifier` dialect option was added (https://github.com/apache/datafusion-sqlparser-rs/pull/1398), the main concern was PostgreSQL. Modern clickhouse supports all of:

unquoted intervals

```
SELECT INTERVAL 1 DAY;

┌─toIntervalDay(1)─┐
1. │ 1 │
└──────────────────┘
```

quoted intervals

```
SELECT INTERVAL '1 d';

┌─toIntervalDay(1)─┐
1. │ 1 │
└──────────────────┘
```

Mixed intervals

```
SELECT INTERVAL '1 2:3:4' DAY TO SECOND;

┌─(toIntervalDay(1), toIntervalHour(2), toIntervalMinute(3), toIntervalSecond(4))─┐
1. │ (1,2,3,4) │
└─────────────────────────────────────────────────────────────────────────────────┘
```

---

The fix should be as simple as flipping one boolean [here](https://github.com/apache/datafusion-sqlparser-rs/blob/bf1741bee2acb8013660de21d314533fe5686e93/src/dialect/clickhouse.rs#L47-L49)

Contributor guide

No contributing guide indexed for this repository

Research direction

Open src/dialect/clickhouse.rs at the require_interval_qualifier setting and inspect the existing boolean. Adjust that setting so ClickHouse accepts unquoted, quoted, and mixed intervals as shown in the issue; done means those three examples no longer require an interval qualifier.

Written by the indexing model from the issue text.

Assessment

Tech stack
clickhouse, rust
Domain
databases
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.