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


##########
python/pyiceberg/expressions/literals.py:
##########
@@ -356,18 +326,26 @@ def _(self, type_var: DecimalType) -> Literal[Decimal]:
         return DecimalLiteral(Decimal(self.value).quantize(Decimal((0, (1,), 
-type_var.scale)), rounding=ROUND_HALF_UP))
 
 
-class DateLiteral(Literal[int]):
-    def __init__(self, value: int):
-        super().__init__(value, int)
+class DateLiteral(Literal[date]):
+    def __init__(self, value: date):
+        super().__init__(value, date)

Review Comment:
   Yes, overload solves it for creating the types. But then we're stuck at the 
next step:
   ```
   def _to_literal(value: Union[U, Literal[T]]) -> Literal[T]:
       if isinstance(value, Literal):
           return value
       else:
           return literal(value)
   ```
   We use this to do things like `EqualTo('co', 'val')`. Actually, we want to 
combine the type here, but this isn't possible with Python generics. It should 
look at the mapping of `literal`, and figure out the result type. For certain 
types, such as `date` we get a `Literal[int]`. 
   
   When using `T`:
   ```
   def _to_literal(value: Union[T, Literal[T]]) -> Literal[T]:
       if isinstance(value, Literal):
           return value
       else:
           return literal(value)
   ```
   We get `Literal[date]` instead.



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

Reply via email to