jaimeferj commented on code in PR #2565:
URL: https://github.com/apache/iceberg-python/pull/2565#discussion_r2445193284


##########
pyiceberg/expressions/__init__.py:
##########
@@ -302,12 +302,19 @@ def __getnewargs__(self) -> Tuple[BooleanExpression, 
BooleanExpression]:
         return (self.left, self.right)
 
 
-class Or(BooleanExpression):
+class Or(IcebergBaseModel, BooleanExpression):
     """OR operation expression - logical disjunction."""
 
+    model_config = ConfigDict(arbitrary_types_allowed=True)
+
+    type: TypingLiteral["str"] = Field(default="or", alias="type")
     left: BooleanExpression
     right: BooleanExpression
 
+    def __init__(self, left: BooleanExpression, right: BooleanExpression, 
*rest: BooleanExpression) -> None:
+        if isinstance(self, Or) and not hasattr(self, "left") and not 
hasattr(self, "right"):
+            super().__init__(left=left, right=right)
+

Review Comment:
   I cannot test it now, but I am pretty sure that I left out `obj.left = left` 
because of how Python works with `__new__`. If you return a class of the same 
type that happens:
   
   > If 
[__new__()](https://docs.python.org/3.12/reference/datamodel.html#object.__new__)
 is invoked during object construction and it returns an instance of cls, then 
the new instance’s 
[__init__()](https://docs.python.org/3.12/reference/datamodel.html#object.__init__)
 method will be invoked like __init__(self[, ...]), where self is the new 
instance and the remaining arguments are the same as were passed to the object 
constructor.
   Ref: https://docs.python.org/3.12/reference/datamodel.html#object.__new__
   
   So that is why I purposely left the object uninitialized, so that when the 
raw obj is returned it is initialized by `__init__`.
   
   If the object has already being initialized by `_build_balanced_tree` I just 
leave it as is.



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