jorisvandenbossche commented on issue #10935:
URL: https://github.com/apache/arrow/issues/10935#issuecomment-903601675


   When doing this in pure python, the field metadata gets preserved:
   
   ```python
   import pyarrow as pa
   import pyarrow.parquet as pq
   
   f = pa.field("a", pa.int64(), metadata={'test': 'value'})
   schema = pa.schema([f])
   table = pa.table({'a': [1, 2, 3]}, schema=schema)
   
   pq.write_table(table, "test_field_metadata.parquet")
   table2 = pq.read_table("test_field_metadata.parquet")
   
   # original table has the field metadata
   >>> table.field('a').metadata
   {b'test': b'value'}
   
   # roundtripped table still has it
   >>> table2.field('a').metadata
   {b'test': b'value'}
   ```
   
   So there is something that is done differently in your C++ example. I think 
this has to do with the saving of the Arrow schema in the Parquet FileMetaData 
or not. This is an option in the `ArrowWriterProperties`. In C++ it is set to 
False by default:
   
   
https://github.com/apache/arrow/blob/b220fea6900e964f8fab987e7dacd6ae38c15dca/cpp/src/parquet/properties.h#L661
   
   but in Python we always enable it:
   
   
https://github.com/apache/arrow/blob/b220fea6900e964f8fab987e7dacd6ae38c15dca/python/pyarrow/_parquet.pyx#L1294-L1296
   
   You can pass ArrowWriterProperties to the `parquet::arrow::WriteTable` 
function to enable store_schema in your example.


-- 
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