Skip to content

Commit ff70bc3

Browse files
committed
expect a count column in inserts and return that count
1 parent 1dcb532 commit ff70bc3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

datafusion-postgres/src/handlers.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,11 @@ impl SimpleQueryHandler for DfSessionService {
9393
.await
9494
.map_err(|e| PgWireError::ApiError(Box::new(e)))?;
9595

96-
// Get the number of rows affected (typically 1 for INSERT)
97-
let rows_affected = result.iter().map(|batch| batch.num_rows()).sum::<usize>();
96+
// Extract count field from the first batch
97+
let rows_affected = result.first()
98+
.and_then(|batch| batch.column_by_name("count"))
99+
.and_then(|col| col.as_any().downcast_ref::<datafusion::arrow::array::UInt64Array>())
100+
.map_or(0, |array| array.value(0) as usize);
98101

99102
// Create INSERT tag with the affected row count
100103
let tag = Tag::new("INSERT").with_oid(0).with_rows(rows_affected);

0 commit comments

Comments
 (0)