Repository navigation
Description
Describe what's wrong
The SELECT statement should output results normally, but it threw an exception.
Does it reproduce on recent release?
It can be reproduced in the latest version.
How to reproduce
Version: 23.5.1.1 (commit 3e63146)
Easy reproduce in ClickHouse fiddle: https://fiddle.clickhouse.com/7f382e0b-739e-4719-b45e-9596d2a1d1ed
Set up database
create table t1 (c3 String, primary key(c3))engine = MergeTree;
create table t2 (c11 String, primary key(c11))engine = MergeTree;
insert into t1 values ('succeed');
insert into t2 values ('succeed');Bug-triggering query
select
ref_0.c11 as c_2_c30_0
from
t2 as ref_0
cross join (select
ref_1.c3 as c_6_c28_15
from
t1 as ref_1
) as subq_0
where subq_0.c_6_c28_15 = (select c11 from t2 order by c11 limit 1);Expected behavior
The SELECT statement is executed without any error.
Actual behavior
It throws an exception:
Received exception from server (version 23.4.2):
Code: 403. DB::Exception: Received from localhost:9000. DB::Exception: Cannot get JOIN keys from JOIN ON section: 'c_6_c28_15 = (_CAST('succeed', 'Nullable(String)') AS _subquery1)', found keys: [Left keys: [] Right keys [] Condition columns: '', 'equals(c_6_c28_15, _subquery1)']. (INVALID_JOIN_ON_EXPRESSION)
(query: select
ref_0.c11 as c_2_c30_0
from
t2 as ref_0
cross join (select
ref_1.c3 as c_6_c28_15
from
t1 as ref_1
) as subq_0
where subq_0.c_6_c28_15 = (select c11 from t2 order by c11 limit 1);)
Additional context
The earliest reproducible version is 21 in fiddle: https://fiddle.clickhouse.com/66a6a811-1bd9-4071-a708-79fb73b61fb3
Before version 21, the query can be executed without any error (e.g. no error in 20.12.8.5-alpine, https://fiddle.clickhouse.com/bb4eb9ef-58cf-4abb-900d-6bcc2bacb52d). It outputs one row:
┏━━━━━━━━━━━┓
┃ �[1mc_2_c30_0�[0m ┃
┡━━━━━━━━━━━┩
│ succeed │
└───────────┘
Activity
Avogar commentedon May 27, 2023
It works with enabled new analyzer:
@vdimir can you tale a look?
Closes: #50271