hkad98 opened a new issue, #34067:
URL: https://github.com/apache/arrow/issues/34067
### Describe the usage question you have. Please include as many useful
details as possible.
Hello,
I noticed that `pyarrow.dataset.write_dataset` does not store field
metadata. Could you please, tell me if it is expected behavior?
I am using pyarrow version 10.0.1. I also tried 11.0.0, and the behavior is
the same.
```
import pandas as pd
import pyarrow as pa
import pyarrow.dataset
df = pd.DataFrame({'year': [2020, 2022, 2019, 2021],
'n_legs': [2, 4, 5, 100],
'animals': ["Flamingo", "Horse", "Brittle stars",
"Centipede"]})
schema = pa.schema([
pa.field('year', pa.int16(), metadata={"123": b"123"}),
pa.field('n_legs', pa.int64()),
pa.field('animals', pa.string())],
metadata={"xyz": b"xyz"})
print(t.field(0).metadata)
# prints {b'123': b'123'}
pyarrow.dataset.write_dataset(
data=t,
base_dir="xyz",
schema=t.schema,
format="arrow",
)
```
Then load the stored file
```
with pa.memory_map("xyz/part-0.arrow", "r") as source:
table = pa.ipc.open_file(source).read_all()
print(table.field(0).metadata)
# prints None
print(table.schema.metadata)
# prints {b'xyz': b'xyz', b'pandas': ... }
```
As you can see above, schema metadata are preserved.
### Component(s)
Python
--
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]