Skip to content

Commit 9c9b3c4

Browse files
committed
Make UnaryPredicate JSON serializable and add unit test
1 parent 9d333ee commit 9c9b3c4

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

pyiceberg/expressions/__init__.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -431,19 +431,12 @@ def as_bound(self) -> Type[BoundPredicate[L]]: ...
431431

432432
class UnaryPredicate(IcebergBaseModel, UnboundPredicate[Any], ABC):
433433
type: str
434-
column: str
435434

436435
model_config = {"arbitrary_types_allowed": True}
437436

438437
def __init__(self, term: Union[str, UnboundTerm[Any]]):
439-
if isinstance(term, Reference):
440-
term_name = term.name
441-
elif isinstance(term, str):
442-
term_name = term
443-
else:
444-
raise ValueError("term must be a string or Reference")
445-
super().__init__(term=Reference(term_name))
446-
self.column = term_name
438+
unbound = _to_unbound_term(term)
439+
super().__init__(term=unbound)
447440

448441
def bind(self, schema: Schema, case_sensitive: bool = True) -> BoundUnaryPredicate[Any]:
449442
bound_term = self.term.bind(schema, case_sensitive)

0 commit comments

Comments
 (0)