Skip to content

Commit

Permalink
chore(query): fix hash join hang (#17389)
Browse files Browse the repository at this point in the history
* chore(query): fix hash join hang

* chore(test): add sqllogictest
  • Loading branch information
Dousir9 authored Jan 31, 2025
1 parent 1c57f68 commit c2e462e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ impl TransformHashJoinBuild {
}

fn collect(&mut self) -> Result<Event> {
if self.input_port.has_data() {
self.add_data_block(self.input_port.pull_data().unwrap()?);
if self.need_spill() {
return self.next_step(Step::Async(AsyncStep::Spill));
}
}

if self.input_port.is_finished() {
if self.need_check_spill_happen() {
self.next_step(Step::Async(AsyncStep::CheckSpillHappen))
Expand All @@ -176,14 +183,6 @@ impl TransformHashJoinBuild {
} else {
self.next_step(Step::Async(AsyncStep::WaitCollect))
}
} else if self.input_port.has_data() {
self.add_data_block(self.input_port.pull_data().unwrap()?);
if self.need_spill() {
self.next_step(Step::Async(AsyncStep::Spill))
} else {
self.input_port.set_need_data();
Ok(Event::NeedData)
}
} else {
self.input_port.set_need_data();
Ok(Event::NeedData)
Expand Down
3 changes: 3 additions & 0 deletions tests/sqllogictests/suites/query/join/join.test
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,6 @@ select * from (select number from numbers(5)) t2 full outer join (select a, 'A'

statement ok
drop table if exists t;

statement ok
with v2 as (SELECT 'xx' || cast(number as string) AS invoice_nr FROM numbers(135) group by invoice_nr order by invoice_nr) select v2.invoice_nr from v2 where EXISTS (SELECT cast(number as string) AS invoice_nr FROM numbers(800) where v2.invoice_nr = cast(number as string)) ignore_result;

0 comments on commit c2e462e

Please sign in to comment.