@@ -743,12 +743,18 @@ def as_bound(self) -> Type[BoundNotIn[L]]:
743743 return BoundNotIn [L ]
744744
745745
746- class LiteralPredicate (UnboundPredicate [L ], ABC ):
747- literal : Literal [L ]
746+ class LiteralPredicate (IcebergBaseModel , UnboundPredicate [L ], ABC ):
747+ type : TypingLiteral ["lt" , "lt-eq" , "gt" , "gt-eq" , "eq" , "not-eq" , "starts-with" , "not-starts-with" ] = Field (alias = "type" )
748+ term : UnboundTerm [Any ]
749+ value : Literal [L ] = Field ()
750+ model_config = ConfigDict (populate_by_name = True , frozen = True , arbitrary_types_allowed = True )
748751
749- def __init__ (self , term : Union [str , UnboundTerm [Any ]], literal : Union [L , Literal [L ]]): # pylint: disable=W0621
750- super ().__init__ (term )
751- self .literal = _to_literal (literal ) # pylint: disable=W0621
752+ def __init__ (self , term : Union [str , UnboundTerm [Any ]], literal : Union [L , Literal [L ]]):
753+ super ().__init__ (term = _to_unbound_term (term ), value = _to_literal (literal )) # type: ignore[call-arg]
754+
755+ @property
756+ def literal (self ) -> Literal [L ]:
757+ return self .value
752758
753759 def bind (self , schema : Schema , case_sensitive : bool = True ) -> BoundLiteralPredicate [L ]:
754760 bound_term = self .term .bind (schema , case_sensitive )
@@ -773,6 +779,10 @@ def __eq__(self, other: Any) -> bool:
773779 return self .term == other .term and self .literal == other .literal
774780 return False
775781
782+ def __str__ (self ) -> str :
783+ """Return the string representation of the LiteralPredicate class."""
784+ return f"{ str (self .__class__ .__name__ )} (term={ repr (self .term )} , literal={ repr (self .literal )} )"
785+
776786 def __repr__ (self ) -> str :
777787 """Return the string representation of the LiteralPredicate class."""
778788 return f"{ str (self .__class__ .__name__ )} (term={ repr (self .term )} , literal={ repr (self .literal )} )"
@@ -886,6 +896,8 @@ def as_unbound(self) -> Type[NotStartsWith[L]]:
886896
887897
888898class EqualTo (LiteralPredicate [L ]):
899+ type : TypingLiteral ["eq" ] = Field (default = "eq" , alias = "type" )
900+
889901 def __invert__ (self ) -> NotEqualTo [L ]:
890902 """Transform the Expression into its negated version."""
891903 return NotEqualTo [L ](self .term , self .literal )
@@ -896,6 +908,8 @@ def as_bound(self) -> Type[BoundEqualTo[L]]:
896908
897909
898910class NotEqualTo (LiteralPredicate [L ]):
911+ type : TypingLiteral ["not-eq" ] = Field (default = "not-eq" , alias = "type" )
912+
899913 def __invert__ (self ) -> EqualTo [L ]:
900914 """Transform the Expression into its negated version."""
901915 return EqualTo [L ](self .term , self .literal )
@@ -906,6 +920,8 @@ def as_bound(self) -> Type[BoundNotEqualTo[L]]:
906920
907921
908922class LessThan (LiteralPredicate [L ]):
923+ type : TypingLiteral ["lt" ] = Field (default = "lt" , alias = "type" )
924+
909925 def __invert__ (self ) -> GreaterThanOrEqual [L ]:
910926 """Transform the Expression into its negated version."""
911927 return GreaterThanOrEqual [L ](self .term , self .literal )
@@ -916,6 +932,8 @@ def as_bound(self) -> Type[BoundLessThan[L]]:
916932
917933
918934class GreaterThanOrEqual (LiteralPredicate [L ]):
935+ type : TypingLiteral ["gt-eq" ] = Field (default = "gt-eq" , alias = "type" )
936+
919937 def __invert__ (self ) -> LessThan [L ]:
920938 """Transform the Expression into its negated version."""
921939 return LessThan [L ](self .term , self .literal )
@@ -926,6 +944,8 @@ def as_bound(self) -> Type[BoundGreaterThanOrEqual[L]]:
926944
927945
928946class GreaterThan (LiteralPredicate [L ]):
947+ type : TypingLiteral ["gt" ] = Field (default = "gt" , alias = "type" )
948+
929949 def __invert__ (self ) -> LessThanOrEqual [L ]:
930950 """Transform the Expression into its negated version."""
931951 return LessThanOrEqual [L ](self .term , self .literal )
@@ -936,6 +956,8 @@ def as_bound(self) -> Type[BoundGreaterThan[L]]:
936956
937957
938958class LessThanOrEqual (LiteralPredicate [L ]):
959+ type : TypingLiteral ["lt-eq" ] = Field (default = "lt-eq" , alias = "type" )
960+
939961 def __invert__ (self ) -> GreaterThan [L ]:
940962 """Transform the Expression into its negated version."""
941963 return GreaterThan [L ](self .term , self .literal )
@@ -946,6 +968,8 @@ def as_bound(self) -> Type[BoundLessThanOrEqual[L]]:
946968
947969
948970class StartsWith (LiteralPredicate [L ]):
971+ type : TypingLiteral ["starts-with" ] = Field (default = "starts-with" , alias = "type" )
972+
949973 def __invert__ (self ) -> NotStartsWith [L ]:
950974 """Transform the Expression into its negated version."""
951975 return NotStartsWith [L ](self .term , self .literal )
@@ -956,6 +980,8 @@ def as_bound(self) -> Type[BoundStartsWith[L]]:
956980
957981
958982class NotStartsWith (LiteralPredicate [L ]):
983+ type : TypingLiteral ["not-starts-with" ] = Field (default = "not-starts-with" , alias = "type" )
984+
959985 def __invert__ (self ) -> StartsWith [L ]:
960986 """Transform the Expression into its negated version."""
961987 return StartsWith [L ](self .term , self .literal )
0 commit comments