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


##########
python/pyiceberg/expressions/visitors.py:
##########
@@ -678,6 +705,59 @@ def visit_less_than_or_equal(self, term: BoundTerm[L], 
literal: Literal[L]) -> b
 
         return ROWS_MIGHT_MATCH
 
+    def visit_starts_with(self, term: BoundTerm[L], literal: Literal[L]) -> 
bool:
+        pos = term.ref().accessor.position
+        field = self.partition_fields[pos]
+        prefix = str(literal.value)
+        len_prefix = len(prefix)
+
+        if not field.lower_bound:
+            return ROWS_CANNOT_MATCH
+
+        lower = _from_byte_buffer(term.ref().field.field_type, 
field.lower_bound)
+        # truncate lower bound so that its length is not greater than the 
length of prefix
+        if lower and lower[:len_prefix] > prefix:
+            return ROWS_CANNOT_MATCH
+
+        if not field.upper_bound:

Review Comment:
   ```suggestion
           if field.upper_bound is None:
   ```



##########
python/pyiceberg/expressions/visitors.py:
##########
@@ -678,6 +705,59 @@ def visit_less_than_or_equal(self, term: BoundTerm[L], 
literal: Literal[L]) -> b
 
         return ROWS_MIGHT_MATCH
 
+    def visit_starts_with(self, term: BoundTerm[L], literal: Literal[L]) -> 
bool:
+        pos = term.ref().accessor.position
+        field = self.partition_fields[pos]
+        prefix = str(literal.value)
+        len_prefix = len(prefix)
+
+        if not field.lower_bound:
+            return ROWS_CANNOT_MATCH
+
+        lower = _from_byte_buffer(term.ref().field.field_type, 
field.lower_bound)
+        # truncate lower bound so that its length is not greater than the 
length of prefix
+        if lower and lower[:len_prefix] > prefix:
+            return ROWS_CANNOT_MATCH
+
+        if not field.upper_bound:
+            return ROWS_CANNOT_MATCH
+
+        upper = _from_byte_buffer(term.ref().field.field_type, 
field.upper_bound)
+        # truncate upper bound so that its length is not greater than the 
length of prefix
+        if upper and upper[:len_prefix] < prefix:

Review Comment:
   ```suggestion
           if upper is not None and upper[:len_prefix] < prefix:
   ```



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