Fokko commented on code in PR #6141: URL: https://github.com/apache/iceberg/pull/6141#discussion_r1019453639
########## python/pyiceberg/expressions/literals.py: ########## @@ -125,81 +127,73 @@ def literal(value) -> Literal: @literal.register(bool) -def _(value: bool) -> Literal[bool]: +def _(value: bool) -> BooleanLiteral: return BooleanLiteral(value) @literal.register(int) -def _(value: int) -> Literal[int]: +def _(value: int) -> LongLiteral: return LongLiteral(value) @literal.register(float) -def _(value: float) -> Literal[float]: +def _(value: float) -> DoubleLiteral: # expression binding can convert to FloatLiteral if needed return DoubleLiteral(value) @literal.register(str) -def _(value: str) -> Literal[str]: +def _(value: str) -> StringLiteral: return StringLiteral(value) @literal.register(UUID) -def _(value: UUID) -> Literal[UUID]: +def _(value: UUID) -> UUIDLiteral: return UUIDLiteral(value) @literal.register(bytes) -def _(value: bytes) -> Literal[bytes]: +def _(value: bytes) -> BinaryLiteral: # expression binding can convert to FixedLiteral if needed return BinaryLiteral(value) @literal.register(bytearray) -def _(value: bytearray) -> Literal[bytes]: +def _(value: bytearray) -> BinaryLiteral: return BinaryLiteral(bytes(value)) @literal.register(Decimal) -def _(value: Decimal) -> Literal[Decimal]: +def _(value: Decimal) -> DecimalLiteral: return DecimalLiteral(value) @literal.register(date) -def _(value: date) -> Literal[int]: +def _(value: date) -> DateLiteral: return DateLiteral(date_to_days(value)) -class AboveMax(Singleton): - @property - def value(self): - raise ValueError("AboveMax has no value") - - def to(self, type_var): +class AboveMax(Literal): + @singledispatchmethod Review Comment: Added! ########## python/pyiceberg/expressions/literals.py: ########## @@ -309,23 +303,23 @@ def __init__(self, value: float): super().__init__(value, float) @singledispatchmethod - def to(self, type_var): - return None + def to(self, type_var: IcebergType) -> Literal: + raise TypeError(f"Cannot convert DoubleLiteral into {type_var}") @to.register(DoubleType) - def _(self, type_var: DoubleType) -> Literal[float]: + def _(self, _: DoubleType) -> Literal[float]: return self @to.register(FloatType) - def _(self, _: FloatType) -> Union[AboveMax, BelowMin, Literal[float]]: + def _(self, _: FloatType) -> Union[AboveMax, BelowMin, FloatLiteral]: if FloatType.max < self.value: - return AboveMax() + return AboveMax(FloatType.max, float) Review Comment: Added! -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org