hililiwei commented on code in PR #7254:
URL: https://github.com/apache/iceberg/pull/7254#discussion_r1159231201


##########
flink/v1.17/flink/src/test/java/org/apache/iceberg/flink/source/TestFlinkTableSource.java:
##########
@@ -542,14 +542,24 @@ public void testFilterPushDownLike() {
     Assert.assertEquals("Should create only one scan", 1, scanEventCount);
     Assert.assertEquals(
         "Should contain the push down filter", expectedFilter, 
lastScanEvent.filter().toString());
+
+    sqlLike = "SELECT * FROM  " + TABLE_NAME + "  WHERE data LIKE '%%' ";
+    resultLike = sql(sqlLike);
+    Assert.assertEquals("Should have 2 records", 2, resultLike.size());
+    List<Row> expectedRecords =
+        Lists.newArrayList(Row.of(1, "iceberg", 10.0), Row.of(2, "b", 20.0));
+    assertSameElements(expectedRecords, resultLike);
+    String expectedScan = "not_null(ref(name=\"data\"))";
+    Assert.assertEquals(
+        "Should contain the push down filter", expectedScan, 
lastScanEvent.filter().toString());
   }
 
   @Test
   public void testFilterNotPushDownLike() {
     Row expectRecord = Row.of(1, "iceberg", 10.0);
     String sqlNoPushDown = "SELECT * FROM " + TABLE_NAME + " WHERE data LIKE 
'%%i' ";
     List<Row> resultLike = sql(sqlNoPushDown);
-    Assert.assertEquals("Should have 1 record", 0, resultLike.size());
+    Assert.assertEquals("Should have 0 record", 0, resultLike.size());

Review Comment:
   > I thought `%%i` meant a string ending with char `i`. that is why it 
shouldn't match any rows. why does it match the row `iceberg` in 1.16. There is 
still sth I am not understanding here.
   
   What i say `%%i is equivalent to startWith('%i')`  means that the filter 
`data LIKE '%%i'` pushed down by flink is `like(data, '%i')`, then 
`FlinkFilters(org.apache.iceberg.flink.FlinkFilters)` will parse it to 
`startWith('%i')`. Because `StartWith`  literal cannot start with `%`, 
`FlinkFilters` has not successfully pushed it down.
   That's how `FlinkFilters` handles this filter in detail.
   
   
https://github.com/apache/iceberg/blob/7c61537194f9ab68e3d83a16b339ec47180f5f10/flink/v1.16/flink/src/main/java/org/apache/iceberg/flink/FlinkFilters.java#L47
   
   
https://github.com/apache/iceberg/blob/7c61537194f9ab68e3d83a16b339ec47180f5f10/flink/v1.16/flink/src/main/java/org/apache/iceberg/flink/FlinkFilters.java#L60-L63
   
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to