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/23 09:50:33 UTC

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

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


##########
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:
   If you would supply the correct literal to the unbound predicate:
   ```
   EqualTo('a', literal(IntegerType.max + 1).to(IntegerType()))
   ```
   Then we would convert this again, and raise an exception. I ran into this when writing tests. This is a bit more friendly, and I don't think there is any harm in it to allow this.



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