Fokko commented on code in PR #590:
URL: https://github.com/apache/iceberg-python/pull/590#discussion_r1568710826
##########
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:
I pinged Ryan and he's in favor of adding the aliases 👍
--
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]