This is an automated email from the ASF dual-hosted git repository.

fokko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git


The following commit(s) were added to refs/heads/main by this push:
     new 510915b  Remove sort-order constraint (#349)
510915b is described below

commit 510915b36325bb4788941d0a974bb8bc6177e627
Author: Fokko Driesprong <[email protected]>
AuthorDate: Thu Feb 1 20:39:04 2024 +0100

    Remove sort-order constraint (#349)
---
 pyiceberg/io/pyarrow.py     | 5 ++++-
 pyiceberg/table/__init__.py | 9 ---------
 2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/pyiceberg/io/pyarrow.py b/pyiceberg/io/pyarrow.py
index 7a94ce4..9e05e2d 100644
--- a/pyiceberg/io/pyarrow.py
+++ b/pyiceberg/io/pyarrow.py
@@ -1735,7 +1735,10 @@ def write_file(table: Table, tasks: Iterator[WriteTask]) 
-> Iterator[DataFile]:
         file_format=FileFormat.PARQUET,
         partition=Record(),
         file_size_in_bytes=len(fo),
-        sort_order_id=task.sort_order_id,
+        # After this has been fixed:
+        # https://github.com/apache/iceberg-python/issues/271
+        # sort_order_id=task.sort_order_id,
+        sort_order_id=None,
         # Just copy these from the table for now
         spec_id=table.spec().spec_id,
         equality_ids=None,
diff --git a/pyiceberg/table/__init__.py b/pyiceberg/table/__init__.py
index 16ed9ed..e3975dc 100644
--- a/pyiceberg/table/__init__.py
+++ b/pyiceberg/table/__init__.py
@@ -943,9 +943,6 @@ class Table:
         if len(self.spec().fields) > 0:
             raise ValueError("Cannot write to partitioned tables")
 
-        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:
@@ -976,9 +973,6 @@ class Table:
         if len(self.spec().fields) > 0:
             raise ValueError("Cannot write to partitioned tables")
 
-        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.OVERWRITE if self.current_snapshot() is not 
None else Operation.APPEND,
@@ -2279,9 +2273,6 @@ def _dataframe_to_data_files(table: Table, df: pa.Table) 
-> Iterable[DataFile]:
     if len(table.spec().fields) > 0:
         raise ValueError("Cannot write to partitioned tables")
 
-    if len(table.sort_order().fields) > 0:
-        raise ValueError("Cannot write to tables with a sort-order")
-
     write_uuid = uuid.uuid4()
     counter = itertools.count(0)
 

Reply via email to