Skip to content

Commit 3c3255b

Browse files
authored
fix(query): panic if explaining complex joins (#18538)
1 parent 8b5ac3c commit 3c3255b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/query/service/src/interpreters/interpreter_explain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ impl ExplainInterpreter {
625625
return Ok(None);
626626
}
627627
let meta = metadata.read();
628-
let table_entry = meta.table(source.scan_id);
628+
let table_entry = meta.table(source.table_index);
629629
if let Some(fuse_table) = table_entry.table().as_any().downcast_ref::<FuseTable>() {
630630
let mut dummy_pipeline = Pipeline::create();
631631
let prune_pipeline = fuse_table.do_build_prune_pipeline(

tests/sqllogictests/suites/ydb/select1-1.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,20 @@ order by col2,col6,col3,col5,col4,col1
15891589
222 0 -1 240 28 723
15901590
444 0 2 249 29 743
15911591

1592+
# issues: https://github.com/databendlabs/databend/issues/18536
1593+
statement ok
1594+
explain SELECT CASE a+1 WHEN b THEN 111 WHEN c THEN 222
1595+
WHEN d THEN 333 WHEN e THEN 444 ELSE 555 END AS col1,
1596+
(SELECT COUNT(*) FROM t1 AS x WHERE x.c>t1.c AND x.d<t1.d) AS col2,
1597+
d-e AS col3,
1598+
b AS col4,
1599+
(SELECT COUNT(*) FROM t1 AS x WHERE x.b<t1.b) AS col5,
1600+
a+b*2 AS col6
1601+
FROM t1
1602+
WHERE EXISTS(SELECT 1 FROM t1 AS x WHERE x.b<t1.b)
1603+
OR (a>b-2 AND a<b+2)
1604+
ORDER BY col2,col6,col3,col5,col4,col1
1605+
15921606
query III
15931607
select a as col1,
15941608
c-d as col2,

0 commit comments

Comments
 (0)