yashwantbezawada opened a new pull request, #48669:
URL: https://github.com/apache/arrow/pull/48669

   ## Summary
   
   Fixes #48024
   
   Both `Table::RenameColumns()` and `RecordBatch::RenameColumns()` were 
dropping schema metadata when creating the renamed table/batch. This also 
affected `Schema::WithNames()` which had the same issue.
   
   ### Root Cause
   The methods were creating new schemas using `::arrow::schema(fields)` 
without passing the original schema's metadata.
   
   ### Fix
   Pass `schema()->metadata()` when constructing the new schema, following the 
same pattern used by `SelectColumns()` and `Flatten()`.
   
   ### Changes
   - Fix `Table::RenameColumns()` in `table.cc`
   - Fix `RecordBatch::RenameColumns()` in `record_batch.cc`  
   - Fix `Schema::WithNames()` in `type.cc`
   - Add C++ tests for all three fixes
   - Add Python test for both Table and RecordBatch
   
   ## Test Plan
   - [x] Added `TestTable::RenameColumnsPreservesMetadata` in `table_test.cc`
   - [x] Added `TestRecordBatch::RenameColumnsPreservesMetadata` in 
`record_batch_test.cc`
   - [x] Added `TestSchema::TestWithNamesPreservesMetadata` in `type_test.cc`
   - [x] Added `test_rename_columns_preserves_metadata` in `test_table.py` 
(parametrized for Table and RecordBatch)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to