rdblue commented on code in PR #41:
URL: https://github.com/apache/iceberg-python/pull/41#discussion_r1427430202
##########
pyiceberg/io/pyarrow.py:
##########
@@ -1565,13 +1564,54 @@ def fill_parquet_file_metadata(
del upper_bounds[field_id]
del null_value_counts[field_id]
- df.file_format = FileFormat.PARQUET
df.record_count = parquet_metadata.num_rows
- df.file_size_in_bytes = file_size
df.column_sizes = column_sizes
df.value_counts = value_counts
df.null_value_counts = null_value_counts
df.nan_value_counts = nan_value_counts
df.lower_bounds = lower_bounds
df.upper_bounds = upper_bounds
df.split_offsets = split_offsets
+
+
+def write_file(table: Table, tasks: Iterator[WriteTask]) -> Iterator[DataFile]:
+ task = next(tasks)
+
+ try:
+ _ = next(tasks)
+ # If there are more tasks, raise an exception
+ raise ValueError("Only unpartitioned writes are supported:
https://github.com/apache/iceberg-python/issues/208")
+ except StopIteration:
+ pass
+
+ df = task.df
+
+ file_path =
f'{table.location()}/data/{_generate_datafile_filename("parquet")}'
Review Comment:
Can the `_generate_datafile_filename` method be a bit more robust? The UUID
in the filename is not for uniqueness, it is to identify files from the same
write. Here's a breakdown of the format used by Spark:
```
\d\d\d\d\d-\d-(UUID)-\d.(extension)
^^^^^^^^^^ ^^ ^^
|||||||||| || counter to distinguish files from the same task
|||||||||| unique task ID from the process (never repeats even for tasks
that are retried)
5-digit "partition number" that is the ordinal of a task within a Spark
stage
```
Uniqueness is a combination of the task ID, the write-specific UUID, and the
file counter for the task. The partition ordinal is used to preserve locality
in file names.
It would be nice to expose some of these options in the WriteTask, like a
unique UUID, unique task ID, and part ordinal. Then the counter would be
handled locally.
--
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]