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


##########
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:
   Does it make sense to produce a commit at all?



##########
pyiceberg/io/pyarrow.py:
##########
@@ -1339,7 +1339,10 @@ def update_min(self, val: Any) -> None:
     def update_max(self, val: Any) -> None:
         self.current_max = val if self.current_max is None else max(val, 
self.current_max)
 
-    def min_as_bytes(self) -> bytes:
+    def min_as_bytes(self) -> Optional[bytes]:

Review Comment:
   Interesting, it is only affecting the bytes?



##########
tests/integration/test_writes.py:
##########
@@ -142,6 +142,54 @@ def arrow_table_with_null() -> pa.Table:
     return pa.Table.from_pydict(TEST_DATA_WITH_NULL, schema=pa_schema)
 
 
[email protected](scope="session")
+def arrow_table_without_data() -> pa.Table:
+    """PyArrow table with all kinds of columns"""
+    pa_schema = pa.schema([

Review Comment:
   Should we put this schema in it's own fixture?



##########
tests/integration/test_writes.py:
##########
@@ -142,6 +142,54 @@ def arrow_table_with_null() -> pa.Table:
     return pa.Table.from_pydict(TEST_DATA_WITH_NULL, schema=pa_schema)
 
 
[email protected](scope="session")
+def arrow_table_without_data() -> pa.Table:
+    """PyArrow table with all kinds of columns"""
+    pa_schema = pa.schema([
+        ("bool", pa.bool_()),
+        ("string", pa.string()),
+        ("string_long", pa.string()),
+        ("int", pa.int32()),
+        ("long", pa.int64()),
+        ("float", pa.float32()),
+        ("double", pa.float64()),
+        ("timestamp", pa.timestamp(unit="us")),
+        ("timestamptz", pa.timestamp(unit="us", tz="UTC")),
+        ("date", pa.date32()),
+        # Not supported by Spark
+        # ("time", pa.time64("us")),
+        # Not natively supported by Arrow
+        # ("uuid", pa.fixed(16)),
+        ("binary", pa.binary()),
+        ("fixed", pa.binary(16)),
+    ])
+    return pa.Table.from_pylist([], schema=pa_schema)
+
+
[email protected](scope="session")
+def arrow_table_with_only_nulls() -> pa.Table:
+    """PyArrow table with all kinds of columns"""
+    pa_schema = pa.schema([
+        ("bool", pa.bool_()),
+        ("string", pa.string()),
+        ("string_long", pa.string()),

Review Comment:
   Seem to be identical?



-- 
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]

Reply via email to