openinx commented on a change in pull request #1893:
URL: https://github.com/apache/iceberg/pull/1893#discussion_r553165643
##########
File path:
flink/src/test/java/org/apache/iceberg/flink/TestFlinkTableSource.java
##########
@@ -75,32 +95,396 @@ public void clean() {
@Test
public void testLimitPushDown() {
- sql("INSERT INTO %s VALUES (1,'a'),(2,'b')", TABLE_NAME);
-
String querySql = String.format("SELECT * FROM %s LIMIT 1", TABLE_NAME);
String explain = getTableEnv().explainSql(querySql);
String expectedExplain = "LimitPushDown : 1";
Assert.assertTrue("explain should contains LimitPushDown",
explain.contains(expectedExplain));
List<Object[]> result = sql(querySql);
- Assert.assertEquals("should have 1 record", 1, result.size());
- Assert.assertArrayEquals("Should produce the expected records",
result.get(0), new Object[] {1, "a"});
+ assertEquals("should have 1 record", 1, result.size());
+ assertArrayEquals("Should produce the expected records", result.get(0),
new Object[] {1, "a"});
AssertHelpers.assertThrows("Invalid limit number: -1 ",
SqlParserException.class,
() -> sql("SELECT * FROM %s LIMIT -1", TABLE_NAME));
- Assert.assertEquals("should have 0 record", 0, sql("SELECT * FROM %s LIMIT
0", TABLE_NAME).size());
+ assertEquals("should have 0 record", 0, sql("SELECT * FROM %s LIMIT 0",
TABLE_NAME).size());
- String sqlLimitExceed = String.format("SELECT * FROM %s LIMIT 3",
TABLE_NAME);
+ String sqlLimitExceed = String.format("SELECT * FROM %s LIMIT 4",
TABLE_NAME);
List<Object[]> resultExceed = sql(sqlLimitExceed);
- Assert.assertEquals("should have 2 record", 2, resultExceed.size());
+ assertEquals("should have 3 record", 3, resultExceed.size());
List<Object[]> expectedList = Lists.newArrayList();
expectedList.add(new Object[] {1, "a"});
expectedList.add(new Object[] {2, "b"});
- Assert.assertArrayEquals("Should produce the expected records",
resultExceed.toArray(), expectedList.toArray());
+ expectedList.add(new Object[] {3, null});
+ assertArrayEquals("Should produce the expected records",
resultExceed.toArray(), expectedList.toArray());
String sqlMixed = String.format("SELECT * FROM %s WHERE id = 1 LIMIT 2",
TABLE_NAME);
List<Object[]> mixedResult = sql(sqlMixed);
- Assert.assertEquals("should have 1 record", 1, mixedResult.size());
- Assert.assertArrayEquals("Should produce the expected records",
mixedResult.get(0), new Object[] {1, "a"});
+ assertEquals("should have 1 record", 1, mixedResult.size());
+ assertArrayEquals("Should produce the expected records",
mixedResult.get(0), new Object[] {1, "a"});
+ }
+
+ @Test
+ public void testNoFilterPushDown() {
+ String sql = String.format("SELECT * FROM %s ", TABLE_NAME);
+ String explain = getTableEnv().explainSql(sql);
+ assertFalse("explain should no contains FilterPushDown",
explain.contains(expectedFilterPushDownExplain));
+ }
+
+ @Test
+ public void testFilterPushDownEqual() {
+ String sqlLiteralRight = String.format("SELECT * FROM %s WHERE id = 1 ",
TABLE_NAME);
+ String explain = getTableEnv().explainSql(sqlLiteralRight);
+ assertTrue("explain should contains FilterPushDown",
explain.contains(expectedFilterPushDownExplain));
+
+ List<Object[]> result = sql(sqlLiteralRight);
+ assertEquals("should have 1 record", 1, result.size());
+ assertArrayEquals("Should produce the expected record", result.get(0), new
Object[] {1, "a"});
Review comment:
Nit: we could just use the `assertEquals` for two lists, don't have to
convert it to array and then use `assertArrayEquals` ?
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]