Skip to content

Commit

Permalink
defensive handle None
Browse files Browse the repository at this point in the history
Signed-off-by: tison <wander4096@gmail.com>
  • Loading branch information
tisonkun committed Mar 19, 2024
1 parent 9a468c4 commit 7f54845
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/promql/src/extension_plan/series_divide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,20 @@ impl Stream for SeriesDivideStream {
Some(Ok(next_batch)) => next_batch,
None => {
self.num_series += 1;
let batch = self.buffer.take().expect("must be some batch");
return Poll::Ready(Some(Ok(batch)));
return Poll::Ready(self.buffer.take().map(Ok));
}
error => return Poll::Ready(error),
};
let batch = self.buffer.take().expect("must be some batch");
let new_batch = compute::concat_batches(&batch.schema(), &[batch, next_batch])?;
self.buffer = Some(new_batch);
match self.buffer.take() {
None => {
self.buffer = Some(next_batch);
}
Some(batch) => {
let new_batch =
compute::concat_batches(&batch.schema(), &[batch, next_batch])?;
self.buffer = Some(new_batch);
}
}
continue;
} else {
let result_batch = batch.slice(0, same_length);
Expand Down

0 comments on commit 7f54845

Please sign in to comment.