Table.rename_columns() drops schema metadata
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 88
Description
### Describe the bug, including details regarding any error messages, version, and platform.
Example test case to reproduce bug:
```py
import pyarrow
my_schema = pyarrow.schema(
[pyarrow.field("n_legs", pyarrow.int64()), pyarrow.field("animals", pyarrow.string())],
metadata={"source": "zoo"}, # We want to preserve this
)
table = pyarrow.Table.from_arrays([[2, 4], ["Flamingo", "Horse"]], schema=my_schema)
assert table.schema.metadata == {b"source": b"zoo"}
new_table = table.rename_columns(["n", "name"])
assert new_table.schema.metadata == {b"source": b"zoo"} # oh no - conservation efforts gone awry!
```
The last assert fails due to `metadata` being `None`.
versions tested:
- 21.0.0
- 22.0.0
platforms tested:
- windows
most likely need to copy the metadata here:
https://github.com/apache/arrow/blob/44f82a402422237adc32551a26ea20ab45366282/cpp/src/arrow/table.cc#L369
### Component(s)
Python, C++
Contributor guide
Assessment
This issue has not been assessed yet.