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

Block structure mismatch in UnionStep stream: different number of columns when projections are used with JOIN #57194

Closed
antonio2368 opened this issue Nov 24, 2023 · 3 comments · Fixed by #57196

Comments

@antonio2368
Copy link
Member

antonio2368 commented Nov 24, 2023

How to reproduce

CREATE TABLE t1 (id UInt32, s String) Engine = MergeTree ORDER BY id;

CREATE TABLE t2 (id1 UInt32, id2 UInt32) Engine = MergeTree ORDER BY id1;
INSERT INTO t2 SELECT * from generateRandom() LIMIT 100;
ALTER TABLE t2 ADD PROJECTION proj (SELECT id2 ORDER BY id2);
INSERT INTO t2 SELECT * from generateRandom() LIMIT 100;

SELECT s FROM t1 as lhs LEFT JOIN (SELECT * FROM t2 WHERER id2 = 1) as rhs ON lhs.id = rhs.id2;

Received exception from server (version 23.11.1):
Code: 49. DB::Exception: Received from localhost:9000. DB::Exception: Block structure mismatch in UnionStep stream: different number of columns:
id2 UInt32 UInt32(size = 0)
id UInt32 UInt32(size = 0), s String String(size = 0). (LOGICAL_ERROR)

cc @amosbird anything familiar?

@amosbird
Copy link
Collaborator

It's not reproduceable in current master. Do you have some special settings enabled?

@antonio2368
Copy link
Member Author

Sorry, it's not reproduceable by my example, noticed right now I made a change that skipped this check:

 if (candidate.sum_marks >= ordinary_reading_marks)
    continue;

Do you have an idea how to modify my test case to pass this check without any modification to the code?

Regardless of that, we noticed this issue happening on our release builds so it's a real problem.

@amosbird
Copy link
Collaborator

Do you have an idea how to modify my test case to pass this check without any modification to the code?

SELECT s
FROM t1 AS lhs
LEFT JOIN
(
    SELECT *
    FROM t2
    WHERE id2 = 1
) AS rhs ON lhs.id = rhs.id2

This one can reproduce. I will investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants