kbendick commented on a change in pull request #2062:
URL: https://github.com/apache/iceberg/pull/2062#discussion_r554920714



##########
File path: 
api/src/main/java/org/apache/iceberg/expressions/BoundLiteralPredicate.java
##########
@@ -69,6 +69,8 @@ public boolean test(T value) {
         return cmp.compare(value, literal.value()) != 0;
       case STARTS_WITH:
         return String.valueOf(value).startsWith((String) literal.value());
+      case NOT_STARTS_WITH:
+        return !String.valueOf(value).startsWith((String) literal.value());

Review comment:
       The other way to handle this to be similar to the rest of the cases and 
to use the `Comparator` that `literal` brings with it would be to convert the 
`T` to a ByteBuffer, and then truncate it and check equality with the 
ByteBuffer representation of `literal`, as follows.
   
   ```java
   ByteBuffer valueAsBytes = Conversions.toByteBuffer(ref().type(), value);
   ByteBuffer literalAsBytes = literal.toByteBuffer();
   int length = Math.min(valueAsBytes.remaining(), literalAsBytes.remaining());
   Comparators.unsignedBytes(BinaryUtil.truncateBinary(valueAsBytes, length), 
prefixAsBytes)) == 0;
   ```
   
   Or if we wanted to just use the comparator from literal, we might consider 
the following. However, for `CharSequence` etc we would need to truncate like 
we do elsewhere so I don't think that this would be correct.
   
   ```java
   cmp.compare(value, literal.value()) == 0;
   ```




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

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