Skip to content

Commit 1a3e702

Browse files
committed
fix: literalpredicate and _to_unbound only accept str or unbound term
1 parent f1bf81a commit 1a3e702

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

pyiceberg/expressions/__init__.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,8 @@
5252
ConfigDict = dict
5353

5454

55-
def _to_unbound_term(term: Union[str, UnboundTerm[Any], BoundReference[Any]]) -> UnboundTerm[Any]:
56-
if isinstance(term, str):
57-
return Reference(term)
58-
if isinstance(term, UnboundTerm):
59-
return term
60-
if isinstance(term, BoundReference):
61-
return Reference(term.field.name)
62-
raise ValueError(f"Expected UnboundTerm | BoundReference | str, got {type(term).__name__}")
55+
def _to_unbound_term(term: Union[str, UnboundTerm[Any]]) -> UnboundTerm[Any]:
56+
return Reference(term) if isinstance(term, str) else term
6357

6458

6559
def _to_literal_set(values: Union[Iterable[L], Iterable[Literal[L]]]) -> Set[Literal[L]]:
@@ -755,7 +749,7 @@ class LiteralPredicate(IcebergBaseModel, UnboundPredicate[L], ABC):
755749
value: Literal[L] = Field()
756750
model_config = ConfigDict(populate_by_name=True, frozen=True, arbitrary_types_allowed=True)
757751

758-
def __init__(self, term: Union[str, UnboundTerm[Any], BoundReference[Any]], literal: Union[L, Literal[L]]):
752+
def __init__(self, term: Union[str, UnboundTerm[Any]], literal: Union[L, Literal[L]]):
759753
super().__init__(term=_to_unbound_term(term), value=_to_literal(literal)) # type: ignore[call-arg]
760754

761755
@property

0 commit comments

Comments
 (0)