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/26 21:54:16 UTC

[GitHub] [iceberg] rdblue commented on a diff in pull request #6256: Python: Skip in the case of AboveMax and BelowMin

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


##########
python/pyiceberg/expressions/literals.py:
##########
@@ -134,55 +134,83 @@ def literal(value: L) -> Literal[L]:
         raise TypeError(f"Invalid literal value: {repr(value)}")
 
 
-class FloatAboveMax(Literal[float], Singleton):
+class AboveMax(Literal[L]):
+    ...
+
+
+class BelowMin(Literal[L]):
+    ...
+
+
+class FloatAboveMax(AboveMax[float], Singleton):
     def __init__(self):
         super().__init__(FloatType.max, float)
 
+    @singledispatchmethod
     def to(self, type_var: IcebergType) -> Literal:  # type: ignore
         raise TypeError("Cannot change the type of FloatAboveMax")
 
+    @to.register(FloatType)
+    def _(self, _: FloatType) -> Literal[float]:
+        return self
+
     def __repr__(self) -> str:
         return "FloatAboveMax()"
 
     def __str__(self) -> str:
         return "FloatAboveMax"
 
 
-class FloatBelowMin(Literal[float], Singleton):
+class FloatBelowMin(BelowMin[float], Singleton):
     def __init__(self):
         super().__init__(FloatType.min, float)
 
+    @singledispatchmethod
     def to(self, type_var: IcebergType) -> Literal:  # type: ignore
         raise TypeError("Cannot change the type of FloatBelowMin")
 
+    @to.register(FloatType)
+    def _(self, _: FloatType) -> Literal[float]:

Review Comment:
   We generally don't want these to leak outside of expression binding, but I see no harm in making it a bit more friendly.



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