You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by ho...@apache.org on 2024/03/28 09:15:19 UTC

(iceberg-python) branch pyiceberg-0.6.x updated (c207cc6c -> d1747605)

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

honahx pushed a change to branch pyiceberg-0.6.x
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git


    from c207cc6c docs: Add missing release steps (#443)
     new a3710773 docstring: Fix missing commit (#432)
     new d1747605 Correctly convert `partition_spec` and `sort_order` (#544)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 pyiceberg/catalog/__init__.py |  2 ++
 pyiceberg/catalog/dynamodb.py |  1 +
 pyiceberg/catalog/glue.py     |  2 +-
 pyiceberg/catalog/hive.py     |  1 +
 pyiceberg/catalog/rest.py     |  2 ++
 pyiceberg/catalog/sql.py      |  2 +-
 pyiceberg/table/metadata.py   |  7 ++++++-
 tests/table/test_metadata.py  | 17 +++++++++--------
 8 files changed, 23 insertions(+), 11 deletions(-)


(iceberg-python) 01/02: docstring: Fix missing commit (#432)

Posted by ho...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

honahx pushed a commit to branch pyiceberg-0.6.x
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git

commit a3710773a64a3c3f99b5ee2f9f8fccc4c259b35d
Author: Fokko Driesprong <fo...@tabular.io>
AuthorDate: Wed Feb 21 18:22:07 2024 +0100

    docstring: Fix missing commit (#432)
---
 pyiceberg/catalog/__init__.py | 2 ++
 pyiceberg/catalog/dynamodb.py | 1 +
 pyiceberg/catalog/glue.py     | 2 +-
 pyiceberg/catalog/hive.py     | 1 +
 pyiceberg/catalog/rest.py     | 2 ++
 pyiceberg/catalog/sql.py      | 2 +-
 6 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/pyiceberg/catalog/__init__.py b/pyiceberg/catalog/__init__.py
index 6e5dc274..e14b4c94 100644
--- a/pyiceberg/catalog/__init__.py
+++ b/pyiceberg/catalog/__init__.py
@@ -385,6 +385,8 @@ class Catalog(ABC):
 
         Raises:
             NoSuchTableError: If a table with the given identifier does not exist.
+            CommitFailedException: Requirement not met, or a conflict with a concurrent commit.
+            CommitStateUnknownException: Failed due to an internal exception on the side of the catalog.
         """
 
     @abstractmethod
diff --git a/pyiceberg/catalog/dynamodb.py b/pyiceberg/catalog/dynamodb.py
index d5f3b5e1..b7b0f3dd 100644
--- a/pyiceberg/catalog/dynamodb.py
+++ b/pyiceberg/catalog/dynamodb.py
@@ -208,6 +208,7 @@ class DynamoDbCatalog(Catalog):
 
         Raises:
             NoSuchTableError: If a table with the given identifier does not exist.
+            CommitFailedException: Requirement not met, or a conflict with a concurrent commit.
         """
         raise NotImplementedError
 
diff --git a/pyiceberg/catalog/glue.py b/pyiceberg/catalog/glue.py
index 06484cb0..089a30ba 100644
--- a/pyiceberg/catalog/glue.py
+++ b/pyiceberg/catalog/glue.py
@@ -404,7 +404,7 @@ class GlueCatalog(Catalog):
 
         Raises:
             NoSuchTableError: If a table with the given identifier does not exist.
-            CommitFailedException: If the commit failed.
+            CommitFailedException: Requirement not met, or a conflict with a concurrent commit.
         """
         identifier_tuple = self.identifier_to_tuple_without_catalog(
             tuple(table_request.identifier.namespace.root + [table_request.identifier.name])
diff --git a/pyiceberg/catalog/hive.py b/pyiceberg/catalog/hive.py
index aba3c173..4d4370fc 100644
--- a/pyiceberg/catalog/hive.py
+++ b/pyiceberg/catalog/hive.py
@@ -360,6 +360,7 @@ class HiveCatalog(Catalog):
 
         Raises:
             NoSuchTableError: If a table with the given identifier does not exist.
+            CommitFailedException: Requirement not met, or a conflict with a concurrent commit.
         """
         identifier_tuple = self.identifier_to_tuple_without_catalog(
             tuple(table_request.identifier.namespace.root + [table_request.identifier.name])
diff --git a/pyiceberg/catalog/rest.py b/pyiceberg/catalog/rest.py
index b4b9f722..a1cc1b7b 100644
--- a/pyiceberg/catalog/rest.py
+++ b/pyiceberg/catalog/rest.py
@@ -568,6 +568,8 @@ class RestCatalog(Catalog):
 
         Raises:
             NoSuchTableError: If a table with the given identifier does not exist.
+            CommitFailedException: Requirement not met, or a conflict with a concurrent commit.
+            CommitStateUnknownException: Failed due to an internal exception on the side of the catalog.
         """
         response = self._session.post(
             self.url(Endpoints.update_table, prefixed=True, **self._split_identifier_for_path(table_request.identifier)),
diff --git a/pyiceberg/catalog/sql.py b/pyiceberg/catalog/sql.py
index 62a2dac5..0059da66 100644
--- a/pyiceberg/catalog/sql.py
+++ b/pyiceberg/catalog/sql.py
@@ -373,7 +373,7 @@ class SqlCatalog(Catalog):
 
         Raises:
             NoSuchTableError: If a table with the given identifier does not exist.
-            CommitFailedException: If the commit failed.
+            CommitFailedException: Requirement not met, or a conflict with a concurrent commit.
         """
         identifier_tuple = self.identifier_to_tuple_without_catalog(
             tuple(table_request.identifier.namespace.root + [table_request.identifier.name])


(iceberg-python) 02/02: Correctly convert `partition_spec` and `sort_order` (#544)

Posted by ho...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

honahx pushed a commit to branch pyiceberg-0.6.x
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git

commit d17476051a723d6249c9f774ebc54841e8a78650
Author: Honah J <ho...@apache.org>
AuthorDate: Sun Mar 24 22:19:38 2024 -0700

    Correctly convert `partition_spec` and `sort_order` (#544)
---
 pyiceberg/table/metadata.py  |  7 ++++++-
 tests/table/test_metadata.py | 17 +++++++++--------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/pyiceberg/table/metadata.py b/pyiceberg/table/metadata.py
index a5dfb6ce..d5e08cf9 100644
--- a/pyiceberg/table/metadata.py
+++ b/pyiceberg/table/metadata.py
@@ -306,6 +306,11 @@ class TableMetadataV1(TableMetadataCommonFields, IcebergBaseModel):
                 fields = data[PARTITION_SPEC]
                 data[PARTITION_SPECS] = [{SPEC_ID: INITIAL_SPEC_ID, FIELDS: fields}]
                 data[DEFAULT_SPEC_ID] = INITIAL_SPEC_ID
+            elif data.get("partition_spec") is not None:
+                # Promote the spec from partition_spec to partition-specs
+                fields = data["partition_spec"]
+                data[PARTITION_SPECS] = [{SPEC_ID: INITIAL_SPEC_ID, FIELDS: fields}]
+                data[DEFAULT_SPEC_ID] = INITIAL_SPEC_ID
             else:
                 data[PARTITION_SPECS] = [{"field-id": 0, "fields": ()}]
 
@@ -328,7 +333,7 @@ class TableMetadataV1(TableMetadataCommonFields, IcebergBaseModel):
         Returns:
             The TableMetadata with the sort_orders set, if not provided.
         """
-        if not data.get(SORT_ORDERS):
+        if not data.get(SORT_ORDERS) and not data.get("sort_orders"):
             data[SORT_ORDERS] = [UNSORTED_SORT_ORDER]
         return data
 
diff --git a/tests/table/test_metadata.py b/tests/table/test_metadata.py
index 97a7931c..19c9c267 100644
--- a/tests/table/test_metadata.py
+++ b/tests/table/test_metadata.py
@@ -235,6 +235,11 @@ def test_new_table_metadata_with_explicit_v1_format() -> None:
 
     expected_spec = PartitionSpec(PartitionField(source_id=2, field_id=1000, transform=IdentityTransform(), name="bar"))
 
+    expected_sort_order = SortOrder(
+        SortField(source_id=1, transform=IdentityTransform(), direction=SortDirection.ASC, null_order=NullOrder.NULLS_LAST),
+        order_id=1,
+    )
+
     expected = TableMetadataV1(
         location="s3://some_v1_location/",
         table_uuid=actual.table_uuid,
@@ -252,20 +257,16 @@ def test_new_table_metadata_with_explicit_v1_format() -> None:
         snapshots=[],
         snapshot_log=[],
         metadata_log=[],
-        sort_orders=[
-            SortOrder(
-                SortField(
-                    source_id=1, transform=IdentityTransform(), direction=SortDirection.ASC, null_order=NullOrder.NULLS_LAST
-                ),
-                order_id=1,
-            )
-        ],
+        sort_orders=[expected_sort_order],
         default_sort_order_id=1,
         refs={},
         format_version=1,
     )
 
     assert actual.model_dump() == expected.model_dump()
+    assert actual.schemas == [expected_schema]
+    assert actual.partition_specs == [expected_spec]
+    assert actual.sort_orders == [expected_sort_order]
 
 
 def test_invalid_format_version(example_table_metadata_v1: Dict[str, Any]) -> None: