Fokko commented on code in PR #590:
URL: https://github.com/apache/iceberg-python/pull/590#discussion_r1565392095
##########
pyiceberg/io/pyarrow.py:
##########
@@ -1769,27 +1769,33 @@ def data_file_statistics_from_parquet_metadata(
def write_file(io: FileIO, table_metadata: TableMetadata, tasks:
Iterator[WriteTask]) -> Iterator[DataFile]:
- schema = table_metadata.schema()
- arrow_file_schema = schema.as_arrow()
parquet_writer_kwargs =
_get_parquet_writer_kwargs(table_metadata.properties)
-
row_group_size = PropertyUtil.property_as_int(
properties=table_metadata.properties,
property_name=TableProperties.PARQUET_ROW_GROUP_SIZE_BYTES,
default=TableProperties.PARQUET_ROW_GROUP_SIZE_BYTES_DEFAULT,
)
def write_parquet(task: WriteTask) -> DataFile:
+ table_schema = task.schema
+ arrow_table = pa.Table.from_batches(task.record_batches)
+ # if schema needs to be transformed, use the transformed schema and
adjust the arrow table accordingly
+ # otherwise use the original schema
+ if (sanitized_schema := sanitize_column_names(table_schema)) !=
table_schema:
+ file_schema = sanitized_schema
+ arrow_table = to_requested_schema(requested_schema=file_schema,
file_schema=table_schema, table=arrow_table)
+ else:
+ file_schema = table_schema
Review Comment:
My preference is to leave out all this logic when writing Parquet files. It
doesn't affect Parquet files (since the characters are supported). With Iceberg
we resolve the fields by ID, so names are unimportant. I would like to get
@rdblue's opinion since he did the initial work (I also have a meeting with him
tomorrow, and I can ping him there).
--
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]