Apache DataFusion SQL Query Engine
fix(datafusion-cli): solve row count bug adding`saturating_add` to prevent potential overflow (#20185)
dario curreriaeeb0ba07aa8
diff --git a/datafusion-cli/src/exec.rs b/datafusion-cli/src/exec.rsindex abf068db0c..94bd8ee2c4 100644--- a/datafusion-cli/src/exec.rs+++ b/datafusion-cli/src/exec.rs@@ -300,7 +300,7 @@ impl StatementExecutor {let curr_num_rows = batch.num_rows();// Stop collecting results if the number of rows exceeds the limit// results batch should include the last batch that exceeds the limit- if row_count < max_rows + curr_num_rows {+ if row_count < max_rows.saturating_add(curr_num_rows) {// Try to grow the reservation to accommodate the batch in memoryreservation.try_grow(get_record_batch_memory_size(&batch))?;results.push(batch);