-
Notifications
You must be signed in to change notification settings - Fork 8.3k
toDate(nullif('', '')), toDateTime(nullif('', '')) throws Parsing error #7673
Copy link
Copy link
Closed
Labels
bugConfirmed user-visible misbehaviour in official releaseConfirmed user-visible misbehaviour in official releasecomp-datatype-wrapperType modifiers/wrappers (Nullable, LowCardinality, etc.).Type modifiers/wrappers (Nullable, LowCardinality, etc.).
Description
Describe the bug or unexpected behaviour
When casting nullif('', '') to Date/DateTime types using toDate()/toDateTime() ClickHouse returns exceptions:
SQL Error [38]: ClickHouse exception, code: 38, host: *, port: *; Code: 38, e.displayText() = DB::Exception: Cannot parse date: value is too short: Cannot parse Date from String (version 19.15.3.6)
SQL Error [41]: ClickHouse exception, code: 41, host: *, port: *; Code: 41, e.displayText() = DB::Exception: Cannot parse datetime: Cannot parse DateTime from String (version 19.15.3.6)
How to reproduce
Some expected results:
select
toDateTime(NULL)
toDateTime(NULL)
----------------
[NULL] select
toDateTime('')
SQL Error [41]: ClickHouse exception, code: 41, host: *, port: *; Code: 41, e.displayText() = DB::Exception: Cannot parse datetime: Cannot parse DateTime from String (version 19.15.3.6)select
nullif('', '')
nullif('', '')
--------------
[NULL] select
toDateTime(nullif(1, 1))
toDateTime(nullif(1, 1))
------------------------
[NULL]select
toDateTimeOrNull(nullif('', ''))
toDateTimeOrNull(nullif('', ''))
--------------------------------
[NULL]Unexpected behavior:
select
toDateTime(nullif('', ''))
SQL Error [41]: ClickHouse exception, code: 41, host: *, port: *; Code: 41, e.displayText() = DB::Exception: Cannot parse datetime: Cannot parse DateTime from String (version 19.15.3.6)select
toDate(nullif('', ''))
SQL Error [38]: ClickHouse exception, code: 38, host: *, port: *; Code: 38, e.displayText() = DB::Exception: Cannot parse date: value is too short: Cannot parse Date from String (version 19.15.3.6)Expected behavior
select
toDateTime(nullif('', ''))
toDateTime(nullif('', ''))
--------------------------------
[NULL]Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugConfirmed user-visible misbehaviour in official releaseConfirmed user-visible misbehaviour in official releasecomp-datatype-wrapperType modifiers/wrappers (Nullable, LowCardinality, etc.).Type modifiers/wrappers (Nullable, LowCardinality, etc.).