Skip to content

Commit

Permalink
chore(planner): fix unexpected anti semi wrong table_index (databendl…
Browse files Browse the repository at this point in the history
…abs#13977)

* fix unexpected anti semi wrong table_index

* fix test

* fix test

---------

Co-authored-by: BohuTANG <[email protected]>
  • Loading branch information
Dousir9 and BohuTANG authored Dec 11, 2023
1 parent de30450 commit 44ed9fa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/query/sql/src/executor/physical_plans/physical_hash_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,15 @@ impl PhysicalPlanBuilder {
column_projections.contains(&index)
{
let metadata = self.metadata.read();
let unexpected_column = metadata.column(index);
let unexpected_column_info = if let Some(table_index) = unexpected_column.table_index() {
format!("{:?}.{:?}", metadata.table(table_index).name(), unexpected_column.name())
} else {
unexpected_column.name().to_string()
};
return Err(ErrorCode::SemanticError(format!(
"cannot access the {:?}.{:?} in ANTI or SEMI join",
metadata.table(index).name(),
metadata.column(index).name()
"cannot access the {} in ANTI or SEMI join",
unexpected_column_info
)));
}
}
Expand Down
19 changes: 17 additions & 2 deletions tests/sqllogictests/suites/query/join/join.test
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,22 @@ SELECT t2.a FROM t1 LEFT SEMI JOIN t2 ON t1.a = t2.a;
---

statement ok
drop table t1;
drop table if exists t1;

statement ok
drop table t2;
drop table if exists t2;

statement ok
create table t1(a int, b int, c int, d int);

statement ok
insert into t1 values(1, 2, 3, 4);

statement ok
create table t2(a int, b int, c int, d int);

statement ok
insert into t2 values(1, 2, 3, 4);

statement error 1065
SELECT tt1.d FROM t1 RIGHT SEMI JOIN t2 USING(b);

0 comments on commit 44ed9fa

Please sign in to comment.