Fokko commented on PR #2557:
URL: https://github.com/apache/iceberg-python/pull/2557#issuecomment-3380049477

   @Aniketsy I checked out the branch locally, and with the following changes 
the tests should pass:
   
   ```
   ➜  iceberg-python git:(fix/setpredicate-json-serialization) ✗ git diff
   
   diff --git a/pyiceberg/expressions/__init__.py 
b/pyiceberg/expressions/__init__.py
   index 00cb404bb..d0824cc31 100644
   --- a/pyiceberg/expressions/__init__.py
   +++ b/pyiceberg/expressions/__init__.py
   @@ -577,15 +577,14 @@ class NotNaN(UnaryPredicate):
            return BoundNotNaN[L]
    
    
   -class SetPredicate(UnboundPredicate[L], IcebergBaseModel, ABC):
   +class SetPredicate(IcebergBaseModel, UnboundPredicate[L], ABC):
        model_config = ConfigDict(arbitrary_types_allowed=True)
    
   -    type: TypingLiteral["in", "not-in"] = Field(default="in", alias="type")
   +    type: TypingLiteral["in", "not-in"] = Field(default="in")
        literals: Set[Literal[L]] = Field(alias="items")
    
        def __init__(self, term: Union[str, UnboundTerm[Any]], literals: 
Union[Iterable[L], Iterable[Literal[L]]]):
   -        super().__init__(term)
   -        self.literals = _to_literal_set(literals)
   +        super().__init__(term=_to_unbound_term(term), 
items=_to_literal_set(literals))  # type: ignore
    
        def bind(self, schema: Schema, case_sensitive: bool = True) -> 
BoundSetPredicate[L]:
            bound_term = self.term.bind(schema, case_sensitive)
   @@ -737,7 +736,7 @@ class NotIn(SetPredicate[L], ABC):
    
        def __invert__(self) -> In[L]:
            """Transform the Expression into its negated version."""
   -        return NotIn[L](self.term, self.literals)
   +        return In[L](self.term, self.literals)
    
        @property
        def as_bound(self) -> Type[BoundNotIn[L]]:
   diff --git a/tests/expressions/test_expressions.py 
b/tests/expressions/test_expressions.py
   index 5123a62ea..5a0c8c924 100644
   --- a/tests/expressions/test_expressions.py
   +++ b/tests/expressions/test_expressions.py
   @@ -875,12 +875,12 @@ def test_not_in() -> None:
    
    def test_serialize_in() -> None:
        pred = In(term="foo", literals=[1, 2, 3])
   -    assert pred.model_dump_json() == 
'{"type":"in","term":"foo","value":[1,2,3]}'
   +    assert pred.model_dump_json() == 
'{"term":"foo","type":"in","items":[1,2,3]}'
    
    
    def test_serialize_not_in() -> None:
        pred = NotIn(term="foo", literals=[1, 2, 3])
   -    assert pred.model_dump_json() == 
'{"type":"not-in","term":"foo","value":[1,2,3]}'
   +    assert pred.model_dump_json() == 
'{"term":"foo","type":"not-in","items":[1,2,3]}'
    
    
    def test_bound_equal_to(term: BoundReference[Any]) -> None:
   ```


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