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


##########
python/pyiceberg/transforms.py:
##########
@@ -249,6 +294,20 @@ def satisfies_order_of(self, other: Transform) -> bool:
     def result_type(self, source: IcebergType) -> IcebergType:
         return IntegerType()
 
+    def project(self, name: str, pred: BoundPredicate) -> 
Optional[UnboundPredicate]:

Review Comment:
   Nice, thanks! That was one of the areas I was unsure of. Since we can 
simplify this quite a lot on the Python side, it was a bit tricky to translate. 
I also added tests:
   ```python
   def test_projection_day_human(bound_reference_date: BoundReference) -> None:
       date_literal = literal(date(2018, 1, 1))
       assert DayTransform().project("dt", 
BoundEqualTo(term=bound_reference_date, literal=date_literal)) == EqualTo(
           term="dt", literal=literal(17532)
       )  # == 2018, 1, 1
   
       assert DayTransform().project("dt", 
BoundLessThanOrEqual(term=bound_reference_date, literal=date_literal)) == 
LessThanOrEqual(
           term="dt", literal=literal(17532)
       )  # <= 2018, 1, 1
   
       assert DayTransform().project("dt", 
BoundLessThan(term=bound_reference_date, literal=date_literal)) == 
LessThanOrEqual(
           term="dt", literal=literal(17531)
       )  # <= 2017, 12, 31
   
       assert DayTransform().project(
           "dt", BoundGreaterThanOrEqual(term=bound_reference_date, 
literal=date_literal)
       ) == GreaterThanOrEqual(
           term="dt", literal=literal(17532)
       )  # >= 2018, 1, 1
   
       assert DayTransform().project("dt", 
BoundGreaterThan(term=bound_reference_date, literal=date_literal)) == 
GreaterThanOrEqual(
           term="dt", literal=literal(17533)
       )  # >= 2018, 1, 2
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to