File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 3232 Union ,
3333)
3434
35- from pydantic import model_validator
35+ from pydantic import Field , model_validator
3636
3737from pyiceberg .expressions .literals import (
3838 AboveMax ,
Original file line number Diff line number Diff line change @@ -736,6 +736,29 @@ def test_not() -> None:
736736 assert not_ == pickle .loads (pickle .dumps (not_ ))
737737
738738
739+ def test_not_json_serialization_and_deserialization () -> None :
740+ expr = Not (AlwaysFalse ())
741+ json_str = expr .model_dump_json ()
742+ restored = Not .model_validate_json (json_str )
743+ assert isinstance (restored , AlwaysTrue )
744+
745+ expr2 = Not (Not (AlwaysFalse ()))
746+ json_str2 = expr2 .model_dump_json ()
747+ restored2 = Not .model_validate_json (json_str2 )
748+ assert isinstance (restored2 , AlwaysFalse )
749+
750+ class DummyExpr (BooleanExpression ):
751+ def __invert__ (self ) -> BooleanExpression :
752+ return self
753+
754+ dummy = DummyExpr ()
755+ not_dummy = Not (child = dummy )
756+ json_str3 = not_dummy .model_dump_json ()
757+ restored3 = Not .model_validate_json (json_str3 )
758+ assert isinstance (restored3 , Not )
759+ assert isinstance (restored3 .child , DummyExpr )
760+
761+
739762def test_always_true () -> None :
740763 always_true = AlwaysTrue ()
741764 assert str (always_true ) == "AlwaysTrue()"
You can’t perform that action at this time.
0 commit comments