apache / apache/druid

SQL with "timestamp - interval '100' day" returns 400 error

Open
#11,695 3 comments 0 reactions 0 assignees View on GitHub
Area - SQL Bug
Dominant language
Java
Stars
14.1k
Forks
3.8k
Avg merge
2d 58m
Merged PRs (30d)
233

Description

SQL with clause
```sql
timestamp - interval '100' day
```
returns 400 error and the exception isn't logged in the Broker log.

### Affected Version

0.22

### Description

Run this query:
```sql
SELECT
AGE,
"ARRIVAL TIME",
"AVAILABLE TIME",
__time
FROM ds1
WHERE __time >= CURRENT_TIMESTAMP - INTERVAL '100' DAY
```
It returns 400 error.

Debugging shows that this exception is thrown:
```
org.apache.calcite.runtime.CalciteContextException: From line 7, column 37 to line 7, column 54: Interval field value 100 exceeds precision of DAY(2) field
```

Broker doesn't log the error.

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with the supplied SQL query on the affected 0.22 setup, then trace the CalciteContextException through the Broker request path. Done means the interval query no longer returns an unexpected 400 error and the relevant exception is recorded in the Broker log.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.