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;
   ```
   
   Depending on the Type `T`, in the above code snippet we might need to use 
`Comparators.naturalOrder` 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.

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