Skip to content

Wrong index analysis when Date is compared with DateTime #10102

@alexey-milovidov

Description

@alexey-milovidov

This issue has been suggested on 42th ClickHouse meetup that was held online.
The recording is available here: https://www.youtube.com/watch?v=QQSCn6nbyN8 (russian)

Describe the bug

milovidov-desktop :) CREATE TABLE test.index (d Date) ENGINE = MergeTree ORDER BY d

CREATE TABLE test.index
(
    `d` Date
)
ENGINE = MergeTree
ORDER BY d

Ok.

0 rows in set. Elapsed: 0.009 sec. 

milovidov-desktop :) INSERT INTO test.index VALUES ('2020-04-07')

INSERT INTO test.index VALUES

Ok.

1 rows in set. Elapsed: 0.007 sec. 

milovidov-desktop :) SELECT * FROM test.index WHERE d > toDateTime('2020-04-06 23:59:59')

SELECT *
FROM test.index
WHERE d > toDateTime('2020-04-06 23:59:59')

Ok.

0 rows in set. Elapsed: 0.017 sec. 

milovidov-desktop :) SELECT * FROM test.index WHERE identity(d > toDateTime('2020-04-06 23:59:59'))

SELECT *
FROM test.index
WHERE identity(d > toDateTime('2020-04-06 23:59:59'))

┌──────────d─┐
│ 2020-04-07 │
└────────────┘

1 rows in set. Elapsed: 0.023 sec.

Metadata

Metadata

Assignees

Labels

bugConfirmed user-visible misbehaviour in official releasecomp-datetimeDate/DateTime/TimeZone datatypes and date-time semantics.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions