This is an automated email from the ASF dual-hosted git repository.

jeffreyvo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new c24d620e17 chore: avoid copy in `SchemaMapping` (#17344)
c24d620e17 is described below

commit c24d620e17bb459996708f3137782e3a25e1a7b3
Author: Raz Luvaton <16746759+rluva...@users.noreply.github.com>
AuthorDate: Thu Aug 28 13:29:20 2025 +0300

    chore: avoid copy in `SchemaMapping` (#17344)
    
    the copy is very cheap but nonetheless
---
 datafusion/datasource/src/schema_adapter.rs | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/datafusion/datasource/src/schema_adapter.rs 
b/datafusion/datasource/src/schema_adapter.rs
index 5e743a3f0c..16de00500b 100644
--- a/datafusion/datasource/src/schema_adapter.rs
+++ b/datafusion/datasource/src/schema_adapter.rs
@@ -396,8 +396,7 @@ impl SchemaMapper for SchemaMapping {
     /// conversions.
     /// The produced RecordBatch has a schema that contains only the projected 
columns.
     fn map_batch(&self, batch: RecordBatch) -> 
datafusion_common::Result<RecordBatch> {
-        let batch_rows = batch.num_rows();
-        let batch_cols = batch.columns().to_vec();
+        let (_old_schema, batch_cols, batch_rows) = batch.into_parts();
 
         let cols = self
             .projected_table_schema
@@ -421,7 +420,7 @@ impl SchemaMapper for SchemaMapping {
             .collect::<datafusion_common::Result<Vec<_>, _>>()?;
 
         // Necessary to handle empty batches
-        let options = 
RecordBatchOptions::new().with_row_count(Some(batch.num_rows()));
+        let options = 
RecordBatchOptions::new().with_row_count(Some(batch_rows));
 
         let schema = Arc::clone(&self.projected_table_schema);
         let record_batch = RecordBatch::try_new_with_options(schema, cols, 
&options)?;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@datafusion.apache.org
For additional commands, e-mail: commits-h...@datafusion.apache.org

Reply via email to