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

Select from table with Engine=Set does not work with 2 joins #26899

Closed
mrpavlikov opened this issue Jul 28, 2021 · 1 comment · Fixed by #26957
Closed

Select from table with Engine=Set does not work with 2 joins #26899

mrpavlikov opened this issue Jul 28, 2021 · 1 comment · Fixed by #26957

Comments

@mrpavlikov
Copy link

mrpavlikov commented Jul 28, 2021

Bug description

Select from table with Engine=Set does not work with 2 joins.

Affected version

Reproduces on 21.3.15.4

How to reproduce

Creating base table and set table:

CREATE TABLE users (
  userid UInt64
)
ENGINE = MergeTree() ORDER BY (userid);
INSERT INTO users VALUES (1),(2),(3);

CREATE TABLE users_set (
  userid UInt64
)
ENGINE = Set;
INSERT INTO users_set VALUES (1),(2);

-- works
select * from users where userid in users_set;

Adding one more table and one more join:

CREATE TABLE user_names(
    userid UInt64,
    name String
) ENGINE = MergeTree() ORDER BY (userid);

INSERT INTO user_names VALUES (1, 'Batman'), (2, 'Joker'), (3, 'Superman');

-- still works
select userid, name 
from users any left join user_names on (users.userid = user_names.userid) 
where userid in users_set;

And one more table plus 2nd join breaks it:

CREATE TABLE user_real_names(
    uid UInt64,
    real_name String
) ENGINE = MergeTree() ORDER BY (uid);

INSERT INTO user_real_names VALUES (1, 'Bruce Wayne'), (2, 'Unknown'), (3, 'Clark Kent');

--DOES NOT WORK
select 
    users.userid,
    name,
    real_name
from users 
    any left join user_names on (users.userid = user_names.userid) 
    any left join user_real_names on (users.userid = user_real_names.uid)
where users.userid in users_set;

Expected behavior

Working query, just like with one or no joins. Expected output:

1	Batman	Bruce Wayne
2	Joker	Unknown

Error message and/or stacktrace

Unknown column name 'users_set': While processing SELECT

@mrpavlikov mrpavlikov added the bug Confirmed user-visible misbehaviour in official release label Jul 28, 2021
@qoega qoega added comp-joins JOINs feature and removed bug Confirmed user-visible misbehaviour in official release labels Jul 28, 2021
@kolsys
Copy link
Contributor

kolsys commented Jul 28, 2021

21.7.4.18 same issue.

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

Successfully merging a pull request may close this issue.

4 participants