You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/11/09 09:47:23 UTC

[GitHub] [iceberg] Fokko commented on a diff in pull request #6141: Python: Make invalid Literal conversions explicit

Fokko commented on code in PR #6141:
URL: https://github.com/apache/iceberg/pull/6141#discussion_r1017702146


##########
python/pyiceberg/expressions/literals.py:
##########
@@ -125,81 +127,71 @@ 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):

Review Comment:
   Had to turn the `AboveMax` into a literal, since the `to()` always returns a literal.



-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org