You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2021/12/16 19:16:47 UTC

[GitHub] [iceberg] RussellSpitzer commented on a change in pull request #2062: [CORE] Add in a NOT_STARTS_WITH operator

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



##########
File path: api/src/main/java/org/apache/iceberg/expressions/InclusiveMetricsEvaluator.java
##########
@@ -408,6 +408,54 @@ public Boolean or(Boolean leftResult, Boolean rightResult) {
       return ROWS_MIGHT_MATCH;
     }
 
+    @Override
+    public <T> Boolean notStartsWith(BoundReference<T> ref, Literal<T> lit) {
+      Integer id = ref.fieldId();
+
+      // Iceberg does not implement SQL 3-boolean logic. Return ROWS_MIGHT_MATCH
+      // to allow the query engine to make its own decision regarding NULL values.
+      if (mayContainNull(id)) {
+        return ROWS_MIGHT_MATCH;
+      }
+
+      ByteBuffer prefixAsBytes = lit.toByteBuffer();
+
+      Comparator<ByteBuffer> comparator = Comparators.unsignedBytes();
+
+      // notStartsWith will match unless all values must start with the prefix. This happens when the lower and upper
+      // bounds both start with the prefix.
+      if (lowerBounds != null && upperBounds != null &&
+          lowerBounds.containsKey(id) && upperBounds.containsKey(id)) {
+        ByteBuffer lower = lowerBounds.get(id);
+        // if lower is shorter than the prefix, it can't start with the prefix

Review comment:
       I think let's try to keep pronouns out of this since I have difficulty parsing this statement. I'm always confused though.
   
   // if lower is shorter than the prefix then lower doesn't start with the 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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org