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

Types of column 1 in section IN don't match: UInt32 on the left (INDEX scan) #50956

Closed
UnamedRus opened this issue Jun 13, 2023 · 5 comments · May be fixed by #50078
Closed

Types of column 1 in section IN don't match: UInt32 on the left (INDEX scan) #50956

UnamedRus opened this issue Jun 13, 2023 · 5 comments · May be fixed by #50078
Labels
potential bug To be reviewed by developers and confirmed/rejected.

Comments

@UnamedRus
Copy link
Contributor

Describe the issue
IN set doesn't do automatic type casting

How to reproduce

CREATE TABLE tst_in (key UInt32) ENGINE=MergeTree ORDER BY key AS SELECT number FROM numbers(1000000);

SELECT count()
FROM tst_in
WHERE key IN (
    SELECT number
    FROM numbers(1000)
);


Received exception from server (version 23.6.1):
Code: 53. DB::Exception: Received from localhost:9000. DB::Exception: Types of column 1 in section IN don't match: UInt32 on the left, UInt64 on the right. (TYPE_MISMATCH)
(query: SELECT count()
FROM tst_in
WHERE key IN (
    SELECT number
    FROM numbers(1000)
);)


If we disable index analysis it does work

SELECT count()
FROM tst_in
WHERE identity(key IN (
    SELECT number
    FROM numbers(1000)
));

1000


23.6
https://fiddle.clickhouse.com/da1d7790-2140-49bf-a502-d77d1238239f

23.4
https://fiddle.clickhouse.com/28617010-1c3e-4af0-a53a-d000f0d92003

@UnamedRus UnamedRus added the potential bug To be reviewed by developers and confirmed/rejected. label Jun 13, 2023
@canhld94
Copy link
Contributor

@UnamedRus in your opinion, should we cast set elements to UInt32 or cast key to UInt64?

A related MR #50078 solves a different issue, but with a little effort can solve this issue as well.

@UnamedRus
Copy link
Contributor Author

@UnamedRus in your opinion, should we cast set elements to UInt32 or cast key to UInt64?

We need to cast to most subtype, check discussion on similar problem with joins:

#21794 (comment)

@SaltTan
Copy link
Contributor

SaltTan commented Aug 8, 2023

@UnamedRus
Copy link
Contributor Author

Hm, 23.5 have the exception https://fiddle.clickhouse.com/be646054-5a86-4ecb-9fb1-576f70814174

@canhld94 Probably you can be interested in that, some pr between 23.5 and 23.6 fixed this particular issue

@Algunenano
Copy link
Member

Most likely fixed in #49570

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
potential bug To be reviewed by developers and confirmed/rejected.
Projects
None yet
4 participants