Skip to content

date column + WITH FILL timestamp return meaningless dates. #30421

@UnamedRus

Description

@UnamedRus

Describe the unexpected behaviour

If you will try to use date column with WITH FILL based on DateTime values ClickHouse will silently overflow values.
Which can be unexpected if you use toStartOfInterval functions with MONTH / WEEK / DAY / HOUR precision, because some of them returns Date and some of them return DateTime.

How to reproduce
ClickHouse 21.11

SELECT today() AS a
ORDER BY a ASC WITH FILL FROM now() - toIntervalMonth(1) TO now() + toIntervalDay(1) STEP 82600

┌──────────a─┐
│ 2021-10-20 │
└────────────┘
┌──────────a─┐
│ 2105-12-14 │
│ 1973-03-29 │
│ 2019-12-17 │
│ 2066-09-05 │
│ 2113-05-26 │
│ 1980-09-08 │
│ 2027-05-29 │
│ 2074-02-15 │
│ 2120-11-05 │
│ 1988-02-19 │
│ 2034-11-08 │
│ 2081-07-28 │
│ 2128-04-17 │
│ 1995-08-01 │
│ 2042-04-20 │
│ 2089-01-07 │
│ 2135-09-28 │
│ 2003-01-11 │
│ 2049-09-30 │
│ 2096-06-19 │
│ 2143-03-10 │
│ 2010-06-23 │
│ 2057-03-12 │
│ 2103-12-01 │
│ 1971-03-16 │
│ 2017-12-03 │
│ 2064-08-22 │
│ 2111-05-13 │
│ 1978-08-26 │
│ 2025-05-15 │
│ 2072-02-02 │
│ 2118-10-23 │
│ 1986-02-05 │
└────────────┘

34 rows in set. Elapsed: 0.013 sec.


SELECT today() AS a
ORDER BY a ASC WITH FILL FROM now() - toIntervalSecond(1) TO now() + toIntervalSecond(1) STEP 1

┌──────────a─┐
│ 2021-10-20 │
└────────────┘
┌──────────a─┐
│ 2025-07-01 │
│ 2025-07-02 │
└────────────┘

Expected behavior
Disallow mixing Date/DateTime datatypes here or correctly convert them.

Metadata

Metadata

Labels

unexpected behaviourResult is unexpected, but not entirely wrong at the same time.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions