maxdebayser commented on PR #7831:
URL: https://github.com/apache/iceberg/pull/7831#issuecomment-1596144303
> It looks like the metadata is also available on the plain writer, where we
don't have to write a dataset:
>
> ```python
> ➜ Desktop python3
> Python 3.11.3 (main, Apr 7 2023, 20:13:31) [Clang 14.0.0
(clang-1400.0.29.202)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import pyarrow as pa
> >>> table = pa.table({'n_legs': [2, 2, 4, 4, 5, 100],
> ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
"Brittle stars", "Centipede"]})
> >>> import pyarrow.parquet as pq
> >>>
> >>> writer = pq.ParquetWriter('/tmp/vo.parquet', table.schema)
> >>> writer.write_table(table)
> >>> writer.close()
> >>> writer.writer.metadata.row_group(0)
> <pyarrow._parquet.RowGroupMetaData object at 0x1375b9080>
> num_columns: 2
> num_rows: 6
> total_byte_size: 256
> >>> writer.writer.metadata.row_group(0).to_dict()
> {
> 'num_columns': 2,
> 'num_rows': 6,
> 'total_byte_size': 256,
> 'columns': [{
> 'file_offset': 119,
> 'file_path': '',
> 'physical_type': 'INT64',
> 'num_values': 6,
> 'path_in_schema': 'n_legs',
> 'is_stats_set': True,
> 'statistics': {
> 'has_min_max': True,
> 'min': 2,
> 'max': 100,
> 'null_count': 0,
> 'distinct_count': 0,
> 'num_values': 6,
> 'physical_type': 'INT64'
> },
> 'compression': 'SNAPPY',
> 'encodings': ('RLE_DICTIONARY', 'PLAIN', 'RLE'),
> 'has_dictionary_page': True,
> 'dictionary_page_offset': 4,
> 'data_page_offset': 46,
> 'total_compressed_size': 115,
> 'total_uncompressed_size': 117
> }, {
> 'file_offset': 359,
> 'file_path': '',
> 'physical_type': 'BYTE_ARRAY',
> 'num_values': 6,
> 'path_in_schema': 'animal',
> 'is_stats_set': True,
> 'statistics': {
> 'has_min_max': True,
> 'min': 'Brittle stars',
> 'max': 'Parrot',
> 'null_count': 0,
> 'distinct_count': 0,
> 'num_values': 6,
> 'physical_type': 'BYTE_ARRAY'
> },
> 'compression': 'SNAPPY',
> 'encodings': ('RLE_DICTIONARY', 'PLAIN', 'RLE'),
> 'has_dictionary_page': True,
> 'dictionary_page_offset': 215,
> 'data_page_offset': 302,
> 'total_compressed_size': 144,
> 'total_uncompressed_size': 139
> }]
> }
> ```
Thanks for pointing that out, I completely missed the fact that you can get
this data from the ParquetWriter after caling `close()`. That changes
everything.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]