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 2020/12/06 01:10:49 UTC

[GitHub] [iceberg] rdblue commented on a change in pull request #1747: API: add isNaN and notNaN predicates

rdblue commented on a change in pull request #1747:
URL: https://github.com/apache/iceberg/pull/1747#discussion_r536926697



##########
File path: api/src/main/java/org/apache/iceberg/expressions/Expressions.java
##########
@@ -123,51 +124,79 @@ public static Expression not(Expression child) {
     return new UnboundPredicate<>(Expression.Operation.NOT_NULL, expr);
   }
 
+  public static <T> UnboundPredicate<T> isNaN(String name) {
+    return new UnboundPredicate<>(Expression.Operation.IS_NAN, ref(name));
+  }
+
+  public static <T> UnboundPredicate<T> isNaN(UnboundTerm<T> expr) {
+    return new UnboundPredicate<>(Expression.Operation.IS_NAN, expr);
+  }
+
+  public static <T> UnboundPredicate<T> notNaN(String name) {
+    return new UnboundPredicate<>(Expression.Operation.NOT_NAN, ref(name));
+  }
+
+  public static <T> UnboundPredicate<T> notNaN(UnboundTerm<T> expr) {
+    return new UnboundPredicate<>(Expression.Operation.NOT_NAN, expr);
+  }
+
   public static <T> UnboundPredicate<T> lessThan(String name, T value) {
+    validateInput("lessThan", value);

Review comment:
       An easier way to do this is to add the check in [`Literal.from`](https://github.com/apache/iceberg/blob/61702d11723a853b7a43c5db5ab1a1489ecabe5e/api/src/main/java/org/apache/iceberg/expressions/Literals.java#L59). That's where Iceberg enforces that the value cannot be `null`. Since a literal is created for every value that is passed in, we would only need to change that one place instead of all of the factory methods here.
   
   It also ensures that we don't add factory methods later and forget to add the check to them.




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



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