You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "yashwantbezawada (via GitHub)" <gi...@apache.org> on 2025/12/27 09:16:14 UTC

[PR] GH-48024: [C++][Python] Preserve schema metadata in RenameColumns [arrow]

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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-48024: [C++][Python] Preserve schema metadata in RenameColumns [arrow]

Posted by "yashwantbezawada (via GitHub)" <gi...@apache.org>.
yashwantbezawada commented on PR #48669:
URL: https://github.com/apache/arrow/pull/48669#issuecomment-3829623747

   Checking in on this one. Let me know if there's anything I should change.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org