syun64 commented on code in PR #350:
URL: https://github.com/apache/iceberg-python/pull/350#discussion_r1475054618
##########
pyiceberg/table/__init__.py:
##########
@@ -946,10 +946,13 @@ def append(self, df: pa.Table) -> None:
if len(self.sort_order().fields) > 0:
raise ValueError("Cannot write to tables with a sort-order")
- data_files = _dataframe_to_data_files(self, df=df)
merge = _MergingSnapshotProducer(operation=Operation.APPEND,
table=self)
- for data_file in data_files:
- merge.append_data_file(data_file)
+
+ # skip writing data files if the dataframe is empty
Review Comment:
Yeah interestingly that's the current behavior with spark:
where df is empty
```
df.writeTo("iceberg.test.empty").append()
rows = spark.sql(
f"""
SELECT operation, summary
FROM iceberg.test.empty.snapshots
ORDER BY committed_at ASC
"""
).collect()
rows
[Row(operation='append', summary={'spark.app.id':
'spark-application-1706807907810', 'changed-partition-count': '0',
'total-equality-deletes': '0', 'total-position-deletes': '0',
'total-delete-files': '0', 'total-files-size': '0', 'total-records': '0',
'total-data-files': '0'})]
```
--
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]