Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering by dictGet() column leads to TYPE_MISMATCH exception #63944

Open
amoskaliov opened this issue May 16, 2024 · 1 comment
Open

Filtering by dictGet() column leads to TYPE_MISMATCH exception #63944

amoskaliov opened this issue May 16, 2024 · 1 comment
Labels
analyzer Issues and pull-requests related to new analyzer potential bug To be reviewed by developers and confirmed/rejected. st-fixed

Comments

@amoskaliov
Copy link

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.

@amoskaliov amoskaliov added the potential bug To be reviewed by developers and confirmed/rejected. label May 16, 2024
@amoskaliov amoskaliov changed the title Filtering by dict_get() column leads to TYPE_MISMATCH exception Filtering by dictGet() column leads to TYPE_MISMATCH exception May 16, 2024
@Algunenano Algunenano added analyzer Issues and pull-requests related to new analyzer st-fixed labels May 16, 2024
@Algunenano
Copy link
Member

Algunenano commented May 16, 2024

Seems it fails in 24.4 only with the analyzer, but it works fine in current master. Not sure what fixed it and whether it has been backported

https://fiddle.clickhouse.com/654e0bf2-6971-423f-a1c7-4d6dcc8bdf54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer Issues and pull-requests related to new analyzer potential bug To be reviewed by developers and confirmed/rejected. st-fixed
Projects
None yet
Development

No branches or pull requests

2 participants