`TIME_PARSE()` works for constants, fails for columns
- Dominant language
- Java
- Stars
- 14.1k
- Forks
- 3.8k
- Avg merge
- 2d 58m
- Merged PRs (30d)
- 233
Description
### Affected Version
Version: 0.21.1
### Description
SQL Druid provides the [`TIME_PARSE()`](https://druid.apache.org/docs/latest/querying/sql.html#time-functions) function.
Let's try it against the `segments` table. First, verify the data, on a system with only the sample Wikipedia data:
```sql
SELECT
"start"
FROM sys.segments
LIMIT 1
```
Result:
```text
2015-09-12T00:00:00.000Z
```
Now, use `TIME_PARSE()` with the returned value. (OK, the query is kind of lame, but bear with me):
```sql
SELECT
TIME_PARSE('2015-09-12T00:00:00.000Z')
FROM sys.segments
LIMIT 1
```
Result:
```text
2015-09-12T00:00:00.000Z
```
Now, put the two together: we know the `start` column has a perfectly fine timestamp string. Try to parse it:
```sql
SELECT
TIME_PARSE("start")
FROM sys.segments
LIMIT 1
```
This fails:
```text
Error: Unknown exception
cannot translate call TIME_PARSE($t2)
java.lang.RuntimeException
```
Expected that a SQL function would work just as well for columns as for constants.
Note: I was trying to use `TIME_PARSE()` to work around [another issue](https://github.com/apache/druid/issues/11659) that prevents using `MAX()` on a string.
Contributor guide
Research direction
Reproduce the three SQL queries against the sample Wikipedia data, comparing TIME_PARSE() with the literal and the "start" column from sys.segments. Read the SQL function translation path implicated by the cannot translate call error; done means TIME_PARSE("start") returns the parsed timestamp without failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100