CircArgs commented on code in PR #5258:
URL: https://github.com/apache/iceberg/pull/5258#discussion_r919585687
##########
python/pyiceberg/expressions/base.py:
##########
@@ -172,13 +178,33 @@ def bind(self, schema: Schema, case_sensitive: bool) ->
BoundReference[T]:
@dataclass(frozen=True) # type: ignore[misc]
class BoundPredicate(Bound[T], BooleanExpression):
term: BoundReference[T]
- literals: Tuple[Literal[T], ...]
+ literals: Union[Tuple[Literal[T], ...], Literal[T]]
+ literals_len_lb: int = field(init=False, repr=False, hash=False,
compare=False, default=1)
+ literals_len_ub: Optional[int] = field(init=False, repr=False, hash=False,
compare=False, default=1)
+
+ def __post_init__(self):
+ if not isinstance(self.literals, tuple):
+ object.__setattr__(self, "literals", (self.literals,))
+ if not (self.literals_len_lb <= len(self.literals) <=
(self.literals_len_ub or float("inf"))): # type: ignore
+ raise AttributeError(
+ f"{self.__class__} expects a number of literals between at
least {self.literals_len_lb} and at most {self.literals_len_ub or float('inf')}"
+ )
@dataclass(frozen=True) # type: ignore[misc]
class UnboundPredicate(Unbound[T, BooleanExpression], BooleanExpression):
term: Reference[T]
- literals: Tuple[Literal[T], ...]
+ literals: Union[Tuple[Literal[T], ...], Literal[T]]
+ literals_len_lb: int = field(init=False, repr=False, hash=False,
compare=False, default=1)
Review Comment:
I figured `Optional` would imply it could be `None` (would be equivalent to
`int | None` which I don't think makes sense
--
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]