You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "kevinjqliu (via GitHub)" <gi...@apache.org> on 2026/09/13 23:05:50 UTC

[PR] Fix schema equality for empty schemas and identifier fields [iceberg-python]

kevinjqliu opened a new pull request, #3958:
URL: https://github.com/apache/iceberg-python/pull/3958

   # Rationale for this change
   
   Empty schemas are falsy because `Schema` implements `__len__`, so `if not other` incorrectly rejects them. The existing `isinstance` check is enough.
   
   Identifier field IDs are unordered, so compare them as sets. Field order and field details still matter; `schema_id` stays ignored.
   
   ## Are these changes tested?
   
   Yes, 332 schema tests pass, including regressions for both cases.
   
   ## Are there any user-facing changes?
   
   Empty schemas and schemas with reordered identifier IDs now compare equal.


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Fix schema equality for empty schemas and identifier fields [iceberg-python]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on code in PR #3958:
URL: https://github.com/apache/iceberg-python/pull/3958#discussion_r4097996729


##########
pyiceberg/schema.py:
##########
@@ -115,16 +115,13 @@ def __len__(self) -> int:
 
     def __eq__(self, other: Any) -> bool:
         """Return the equality of two instances of the Schema class."""
-        if not other:
-            return False
-
         if not isinstance(other, Schema):
             return False
 
         if len(self.columns) != len(other.columns):
             return False
 
-        identifier_field_ids_is_equal = self.identifier_field_ids == other.identifier_field_ids

Review Comment:
   I don't think the order is important, so a `frozenset` would do 👍 



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Fix schema equality for empty schemas and identifier fields [iceberg-python]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko merged PR #3958:
URL: https://github.com/apache/iceberg-python/pull/3958


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Fix schema equality for empty schemas and identifier fields [iceberg-python]

Posted by "rambleraptor (via GitHub)" <gi...@apache.org>.
rambleraptor commented on code in PR #3958:
URL: https://github.com/apache/iceberg-python/pull/3958#discussion_r4001785192


##########
pyiceberg/schema.py:
##########
@@ -115,16 +115,13 @@ def __len__(self) -> int:
 
     def __eq__(self, other: Any) -> bool:
         """Return the equality of two instances of the Schema class."""
-        if not other:
-            return False
-
         if not isinstance(other, Schema):
             return False
 
         if len(self.columns) != len(other.columns):
             return False
 
-        identifier_field_ids_is_equal = self.identifier_field_ids == other.identifier_field_ids

Review Comment:
   I haven't dug into this at all, but what if we just stored the identifier field IDs as a set?



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Fix schema equality for empty schemas and identifier fields [iceberg-python]

Posted by "kevinjqliu (via GitHub)" <gi...@apache.org>.
kevinjqliu commented on code in PR #3958:
URL: https://github.com/apache/iceberg-python/pull/3958#discussion_r4006918631


##########
pyiceberg/schema.py:
##########
@@ -115,16 +115,13 @@ def __len__(self) -> int:
 
     def __eq__(self, other: Any) -> bool:
         """Return the equality of two instances of the Schema class."""
-        if not other:
-            return False
-
         if not isinstance(other, Schema):
             return False
 
         if len(self.columns) != len(other.columns):
             return False
 
-        identifier_field_ids_is_equal = self.identifier_field_ids == other.identifier_field_ids

Review Comment:
   yea i think that might be a better long term design. Something like `frozenset[int]` would be representative 



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Fix schema equality for empty schemas and identifier fields [iceberg-python]

Posted by "rambleraptor (via GitHub)" <gi...@apache.org>.
rambleraptor commented on code in PR #3958:
URL: https://github.com/apache/iceberg-python/pull/3958#discussion_r4007878417


##########
pyiceberg/schema.py:
##########
@@ -115,16 +115,13 @@ def __len__(self) -> int:
 
     def __eq__(self, other: Any) -> bool:
         """Return the equality of two instances of the Schema class."""
-        if not other:
-            return False
-
         if not isinstance(other, Schema):
             return False
 
         if len(self.columns) != len(other.columns):
             return False
 
-        identifier_field_ids_is_equal = self.identifier_field_ids == other.identifier_field_ids

Review Comment:
   Yeah, that would work great! 



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org