Closed
Description
Describe what's wrong
We have a view with one column defined as dictGet(...)
. When users include this column in WHERE
expression, they get TYPE_MISMATCH
exception.
Does it reproduce on the most recent release?
It does reproduce with 24.4. It doesn't with 24.2 though.
How to reproduce
CREATE TABLE event_types (
`event_type` Int8,
`description` String
)
ENGINE = MergeTree()
ORDER BY (event_type);
INSERT INTO event_types VALUES (-1, 'event_type_-1'), (0, 'event_type_0'), (1, 'event_type_1')
CREATE DICTIONARY event_types_dictionary
(
`event_type` Int8,
`description` String
)
PRIMARY KEY event_type
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() TABLE 'event_types'))
LAYOUT(COMPLEX_KEY_HASHED())
LIFETIME(MIN 0 MAX 1000);
CREATE TABLE events (
`event_id` UInt64,
`event_type` Int8
)
ENGINE = MergeTree()
ORDER BY (event_id, event_type);
INSERT INTO events VALUES (1, -1), (2, 0), (3, 1)
CREATE VIEW events_view AS
SELECT
event_id,
dictGet('event_types_dictionary', 'description', tuple(`event_type`)) AS event_type
FROM events
User prompt:
SELECT *
FROM events_view
WHERE event_type = 'event_type_-1'
Clickhouse 24.4:
Elapsed: 0.003 sec.
Received exception from server (version 24.4.1):
Code: 53. DB::Exception: Received from localhost:9000. DB::Exception: Cannot convert string event_-1 to type Int8. (TYPE_MISMATCH)
Clickhouse 24.2:
┌─event_id─┬─event_type────┐
│ 1 │ event_type_-1 │
└──────────┴───────────────┘
1 row in set. Elapsed: 0.003 sec.
Expected behavior
Clickhouse 24.4 should return result as 24.2 does.