Skip to content

Commit a289ae4

Browse files
committed
fix(sqlite): bounds-check value_col_indices in push_batch
push_batch validated key_col_index but not value_col_indices; an out-of-range entry would panic in row_to_params on batch.column(ci) rather than returning a clean DataFusionError. Validate both, and add a test for the out-of-range value-index case. Addresses PR review nit.
1 parent d88fdaa commit a289ae4

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/sqlite_provider.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,11 @@ impl SqliteSidecarBuilder {
366366
self.key_col_index
367367
)));
368368
}
369+
if let Some(&bad) = self.value_col_indices.iter().find(|&&i| i >= ncols) {
370+
return Err(DataFusionError::Execution(format!(
371+
"value column index {bad} out of range for batch with {ncols} columns"
372+
)));
373+
}
369374
let key_col = batch.column(self.key_col_index);
370375
let mut stmt = self
371376
.conn

tests/sqlite_provider_test.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ fn test_stream_builder_validation_errors() {
254254
.unwrap();
255255
assert!(b_oob.push_batch(&two_col).is_err());
256256

257+
// value_col_index out of range for the pushed batch (clean error, no panic).
258+
let mut b_voob =
259+
SqliteSidecarBuilder::begin(&db("c2.db"), "t", 1, schema.clone(), 0, vec![9]).unwrap();
260+
assert!(b_voob.push_batch(&two_col).is_err());
261+
257262
// A null key value is rejected.
258263
let nullable = Arc::new(Schema::new(vec![
259264
Field::new("rowid", DataType::Int64, true),

0 commit comments

Comments
 (0)