ClickHouse / ClickHouse/ClickHouse
SELECT - There is no supertype for types DateTime, String
- Dominant language
- C++
- Stars
- 49.9k
- Forks
- 9k
- Avg merge
- 20h 33m
- Merged PRs (30d)
- 501
Description
Hello!
I'm faced with an unexpected behaviour which is very similar to #3746.
It's easy to reproduce. The next request:
```sql
SELECT greatest(time, '2021-08-18 10:44:03') AS max_time
FROM
(
SELECT now() AS time
)
```
ends with the error:
```
Received exception from server (version 21.4.6):
Code: 386. DB::Exception: Received from s:9000. DB::Exception: There is no supertype for types DateTime, String because some of them are String/FixedString and some of them are not: While processing greatest(time, '2021-08-18 10:44:03') AS max_time.
```
Possible workaround is to use `toDateTime()` function to explicit cast the string parameter.
```sql
SELECT greatest(time, toDateTime('2021-08-18 10:44:03')) AS max_time
FROM
(
SELECT now() AS time
)
Query id: 091311c2-a7c4-4192-a7b6-d9680c9d1f8d
┌────────────max_time─┐
│ 2021-08-18 10:49:03 │
└─────────────────────┘
1 rows in set. Elapsed: 0.006 sec.
```
The server version is `21.4.6.55`.
Contributor guide
Assessment
This issue has not been assessed yet.