ClickHouse / ClickHouse/ClickHouse

Add common type for Date(Time) and string operations

Open
#44,509 1 comment 0 reactions 0 assignees View on GitHub
comp-datetime feature
Dominant language
C++
Stars
49.9k
Forks
9k
Avg merge
21h 32m
Merged PRs (30d)
515

Description

**Use case**

Column is String with Date inside. It is inconvenient to manually calling CAST or toString every time when we need to compare it with Date variable.
Other way around when column is Date, but you apply function with string as second argument.

Here I added PR with tests that show currently unsupported pairs of types to easier see what to address:
https://github.com/ClickHouse/ClickHouse/pull/44462/

**Describe the solution you'd like**

Add enum setting `string_and_date_common_type=no,date,string` that defines to which common type we should convert this pair of columns.
`no` - is the current behavior when we forbid anything without explicit cast
`date` - string column is converted to Date(Time) using the default DateTime parsing logic configured for server.
`string` - date is converted to String and we perform operations with strings.

**Describe alternatives you've considered**

Choose the single one side of conversion.

**Additional context**

Operations with String + Interval are out of scope like `SELECT '2020-01-01' + INTERVAL 10 DAY` will still require explicit cast to date.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.