yabola commented on code in PR #9710: URL: https://github.com/apache/iceberg/pull/9710#discussion_r1510200997
########## api/src/test/java/org/apache/iceberg/expressions/TestEvaluator.java: ########## @@ -348,6 +352,102 @@ public void testNotStartsWith() { .isTrue(); } + @Test + public void testEndsWith() { + StructType struct = StructType.of(required(24, "s", Types.StringType.get())); + Evaluator evaluator = new Evaluator(struct, endsWith("s", "abc")); + assertThat(evaluator.eval(TestHelpers.Row.of("abc"))) + .as("abc endsWith abc should be true") + .isTrue(); + assertThat(evaluator.eval(TestHelpers.Row.of("bcx"))) + .as("bcx endsWith abc should be false") + .isFalse(); + assertThat(evaluator.eval(TestHelpers.Row.of("abC"))) + .as("abC endsWith abc should be false") + .isFalse(); + assertThat(evaluator.eval(TestHelpers.Row.of("c"))) + .as("c endsWith abc should be false") + .isFalse(); + assertThat(evaluator.eval(TestHelpers.Row.of("aabc"))) + .as("aabc endsWith abc should be true") + .isTrue(); + assertThat(evaluator.eval(TestHelpers.Row.of((String) null))) + .as("null endsWith abc should be false") + .isFalse(); + } + + @Test + public void testNotEndsWith() { + StructType struct = StructType.of(required(24, "s", Types.StringType.get())); + Evaluator evaluator = new Evaluator(struct, notEndsWith("s", "abc")); + assertThat(evaluator.eval(TestHelpers.Row.of("abc"))) + .as("abc notEndsWith abc should be false") + .isFalse(); + assertThat(evaluator.eval(TestHelpers.Row.of("abcx"))) + .as("abcx notEndsWith abc should be true") + .isTrue(); + assertThat(evaluator.eval(TestHelpers.Row.of("abC"))) + .as("abC notEndsWith abc should be true") + .isTrue(); + assertThat(evaluator.eval(TestHelpers.Row.of("c"))) + .as("c notEndsWith abc should be true") + .isTrue(); + assertThat(evaluator.eval(TestHelpers.Row.of("ababc"))) + .as("ababc notEndsWith abc should be false") + .isFalse(); + assertThat(evaluator.eval(TestHelpers.Row.of("AbAbc"))) + .as("AbAbc notEndsWith abc should be true") + .isTrue(); + } + + @Test + public void testContains() { + StructType struct = StructType.of(required(24, "s", Types.StringType.get())); + Evaluator evaluator = new Evaluator(struct, contains("s", "abc")); + assertThat(evaluator.eval(TestHelpers.Row.of("abc"))) + .as("abc contains abc should be true") + .isTrue(); + assertThat(evaluator.eval(TestHelpers.Row.of("bx"))) + .as("bx contains abc should be false") + .isFalse(); + assertThat(evaluator.eval(TestHelpers.Row.of("abC"))) + .as("abC contains abc should be false") + .isFalse(); + assertThat(evaluator.eval(TestHelpers.Row.of("c"))) + .as("c contains abc should be false") + .isFalse(); + assertThat(evaluator.eval(TestHelpers.Row.of("aabca"))) + .as("aabca contains abc should be true") + .isTrue(); + assertThat(evaluator.eval(TestHelpers.Row.of((String) null))) + .as("null contains abc should be false") + .isFalse(); + } + + @Test + public void testNotContains() { Review Comment: add `new Object[] {null}` and empty string -- 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-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org