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

chore(query): fix hash join hang #17389

Merged
merged 2 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;