diff --git a/src/query/service/src/pipelines/processors/transforms/aggregator/transform_aggregate_partial.rs b/src/query/service/src/pipelines/processors/transforms/aggregator/transform_aggregate_partial.rs index ab82d0e1c1d9..d128ed0c268e 100644 --- a/src/query/service/src/pipelines/processors/transforms/aggregator/transform_aggregate_partial.rs +++ b/src/query/service/src/pipelines/processors/transforms/aggregator/transform_aggregate_partial.rs @@ -366,9 +366,12 @@ impl AccumulatingTransform for TransformPartialAggrega Ok(vec![]) } - fn on_finish(&mut self, _output: bool) -> Result> { + fn on_finish(&mut self, output: bool) -> Result> { Ok(match std::mem::take(&mut self.hash_table) { - HashTable::MovedOut => unreachable!(), + HashTable::MovedOut => match !output && std::thread::panicking() { + true => vec![], + false => unreachable!(), + }, HashTable::HashTable(v) => match v.hashtable.len() == 0 { true => vec![], false => vec![DataBlock::empty_with_meta( diff --git a/src/query/service/src/pipelines/processors/transforms/aggregator/transform_group_by_partial.rs b/src/query/service/src/pipelines/processors/transforms/aggregator/transform_group_by_partial.rs index c4035226d598..54786970e52e 100644 --- a/src/query/service/src/pipelines/processors/transforms/aggregator/transform_group_by_partial.rs +++ b/src/query/service/src/pipelines/processors/transforms/aggregator/transform_group_by_partial.rs @@ -232,9 +232,12 @@ impl AccumulatingTransform for TransformPartialGroupBy Ok(vec![]) } - fn on_finish(&mut self, _output: bool) -> Result> { + fn on_finish(&mut self, output: bool) -> Result> { Ok(match std::mem::take(&mut self.hash_table) { - HashTable::MovedOut => unreachable!(), + HashTable::MovedOut => match !output && std::thread::panicking() { + true => vec![], + false => unreachable!(), + }, HashTable::HashTable(cell) => match cell.hashtable.len() == 0 { true => vec![], false => vec![DataBlock::empty_with_meta(