Fokko commented on code in PR #590:
URL: https://github.com/apache/iceberg-python/pull/590#discussion_r1564241452


##########
pyiceberg/io/pyarrow.py:
##########
@@ -1780,16 +1781,17 @@ def write_file(io: FileIO, table_metadata: 
TableMetadata, tasks: Iterator[WriteT
     )
 
     def write_parquet(task: WriteTask) -> DataFile:
+        arrow_table = pa.Table.from_batches(task.record_batches)
+        df = to_requested_schema(requested_schema=parquet_schema, 
file_schema=iceberg_table_schema, table=arrow_table)

Review Comment:
   Do we know if `from_arrays` in the `ArrowProjectionVisitor` is no-op?
   
   The I'm asking is that we're introducing quite a bit of logic here, and I 
think the rewrites are only applicable for Avro: 
https://avro.apache.org/docs/1.8.1/spec.html#names



##########
pyiceberg/io/pyarrow.py:
##########
@@ -1769,8 +1769,9 @@ 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()
+    iceberg_table_schema = table_metadata.schema()
+    parquet_schema = sanitize_column_names(iceberg_table_schema)
+    arrow_file_schema = parquet_schema.as_arrow()

Review Comment:
   Nit: I realize we have many names, but that might be confusing. 
Parquet-schema is appropriate today since we only support parquet, but we might 
also support ORC and Avro later.
   ```suggestion
       arrow_file_schema = 
sanitize_column_names(iceberg_table_schema).as_arrow()
   ```
   



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to