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_r317373662
 
 

 ##########
 File path: api/src/test/java/org/apache/iceberg/expressions/TestEvaluator.java
 ##########
 @@ -362,4 +368,197 @@ public void testCharSeqValue() {
     Assert.assertFalse("string(abc) == utf8(abcd) => false",
         evaluator.eval(TestHelpers.Row.of(new Utf8("abcd"))));
   }
+
+  @Test
+  public void testIn() {
+    Assert.assertEquals(3, in("s", 7, 8, 9).literals().size());
+    Assert.assertEquals(3, in("s", 7, 8.1, Long.MAX_VALUE).literals().size());
+    Assert.assertEquals(2, in("s", "abc", "abd", "abc").literals().size());
+    Assert.assertEquals(0, in("s").literals().size());
+    Assert.assertEquals(1, in("s", 5).literals().size());
+    Assert.assertEquals(1, in("s", 5, 5).literals().size());
+    Assert.assertEquals(1, in("s", Arrays.asList(5, 5)).literals().size());
+    Assert.assertEquals(0, in("s", Collections.emptyList()).literals().size());
+
+    Evaluator evaluator = new Evaluator(STRUCT, in("x", 7, 8, Long.MAX_VALUE));
+    Assert.assertTrue("7 in [7, 8] => true", 
evaluator.eval(TestHelpers.Row.of(7, 8, null)));
+    Assert.assertFalse("9 in [7, 8]  => false", 
evaluator.eval(TestHelpers.Row.of(9, 8, null)));
+
+    Evaluator longEvaluator = new Evaluator(STRUCT,
+        in("x", Long.MAX_VALUE, Integer.MAX_VALUE, Long.MIN_VALUE));
+    Assert.assertTrue("Integer.MAX_VALUE in [Integer.MAX_VALUE] => true",
+        longEvaluator.eval(TestHelpers.Row.of(Integer.MAX_VALUE, 7.0, null)));
+    Assert.assertFalse("6 in [Integer.MAX_VALUE]  => false",
+        longEvaluator.eval(TestHelpers.Row.of(6, 6.8, null)));
+
+    Evaluator integerEvaluator = new Evaluator(STRUCT, in("y", 7, 8, 9.1));
+    Assert.assertTrue("7.0 in [7, 8, 9.1] => true", 
integerEvaluator.eval(TestHelpers.Row.of(7, 7.0, null)));
 
 Review comment:
   It is confusing to have `x=7` here because 7.0 (`y`) is the value you're 
testing in the set. Can you change these to `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:
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