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/10 16:44:12 UTC

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

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


##########
python/pyiceberg/expressions/literals.py:
##########
@@ -58,25 +60,25 @@
     timestamp_to_micros,
     timestamptz_to_micros,
 )
-from pyiceberg.utils.singleton import Singleton
 
 T = TypeVar("T")
 
 
 class Literal(Generic[T], ABC):
     """Literal which has a value and can be converted between types"""
 
-    def __init__(self, value: T, value_type: type):
+    def __init__(self, value: T, value_type: Type):
         if value is None or not isinstance(value, value_type):
             raise TypeError(f"Invalid literal value: {value} (not a {value_type})")
         self._value = value
 
     @property
     def value(self) -> T:
-        return self._value  # type: ignore
+        return self._value
 
+    @singledispatchmethod
     @abstractmethod
-    def to(self, type_var) -> Literal:
+    def to(self, type_var: IcebergType) -> Literal:

Review Comment:
   I think AboveMax and BelowMin should be special literals. That works.



-- 
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