rdblue commented on a change in pull request #357: Add in and not in predicates
URL: https://github.com/apache/incubator-iceberg/pull/357#discussion_r313978735
 
 

 ##########
 File path: api/src/main/java/org/apache/iceberg/expressions/Expressions.java
 ##########
 @@ -109,16 +111,46 @@ public static Expression not(Expression child) {
     return new UnboundPredicate<>(Expression.Operation.STARTS_WITH, ref(name), 
value);
   }
 
+  public static <T> UnboundPredicate<T> in(String name, T value, T... values) {
+    return predicate(Operation.IN, name,
+        Stream.concat(Stream.of(value), Stream.of(values))
+            .map(Literals::from).collect(Collectors.toSet()));
+  }
+
+  public static <T> UnboundPredicate<T> notIn(String name, T value, T... 
values) {
 
 Review comment:
   I'd rather have the signature of these factory methods use just `T...`. I 
see why you'd do this to ensure that there is at least one value, but this is 
the primary way to create predicates and this is difficult to use if you're 
converting from something else because when you have to separate the first 
element from a set of values.
   
   So to make it simpler for callers, this should accept any `T... values`. If 
values is empty, then it should return `alwaysTrue` (or `alwaysFalse` for 
`in`), and return an UnboundPredicate for anything else.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to