slinkydeveloper commented on a change in pull request #18151:
URL: https://github.com/apache/flink/pull/18151#discussion_r837203385



##########
File path: 
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/stream/table/DataGeneratorConnectorITCase.java
##########
@@ -72,4 +77,30 @@ public void testTypes() throws Exception {
 
         assertThat(results).as("Unexpected number of results").hasSize(10);
     }
+
+    @Test
+    public void testLimitPushDown() throws Exception {
+        final TestingTableEnvironment env =
+                TestingTableEnvironment.create(
+                        
EnvironmentSettings.newInstance().inStreamingMode().build(),
+                        null,
+                        new TableConfig());
+
+        env.executeSql(
+                "CREATE TABLE datagen_t (\n"
+                        + "    f0 CHAR(1)\n"
+                        + ") WITH ("
+                        + "    'connector' = 'datagen'"
+                        + ")");
+
+        final Table table = env.sqlQuery("select * from datagen_t limit 5");
+        String[] explain = table.explain().split("==.*==\\s+");
+        assertThat(explain).as("Unexpected number of results").hasSize(4);
+        assertThat(explain[2])
+                .contains(
+                        "table=[[default_catalog, default_database, datagen_t, 
limit=[5]]], fields=[f0]");
+
+        List<Row> rows = 
CollectionUtil.iteratorToList(table.execute().collect());
+        assertThat(rows).as("Unexpected number of results").hasSize(5);

Review comment:
       no need to declare the `rows` variable, inline that

##########
File path: 
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/stream/table/DataGeneratorConnectorITCase.java
##########
@@ -72,4 +77,30 @@ public void testTypes() throws Exception {
 
         assertThat(results).as("Unexpected number of results").hasSize(10);
     }
+
+    @Test
+    public void testLimitPushDown() throws Exception {
+        final TestingTableEnvironment env =
+                TestingTableEnvironment.create(
+                        
EnvironmentSettings.newInstance().inStreamingMode().build(),
+                        null,
+                        new TableConfig());
+
+        env.executeSql(
+                "CREATE TABLE datagen_t (\n"
+                        + "    f0 CHAR(1)\n"
+                        + ") WITH ("
+                        + "    'connector' = 'datagen'"
+                        + ")");
+
+        final Table table = env.sqlQuery("select * from datagen_t limit 5");
+        String[] explain = table.explain().split("==.*==\\s+");
+        assertThat(explain).as("Unexpected number of results").hasSize(4);
+        assertThat(explain[2])
+                .contains(
+                        "table=[[default_catalog, default_database, datagen_t, 
limit=[5]]], fields=[f0]");

Review comment:
       This exception is a bit hard to understand and relies on string 
comparison, can you at least just do the contains on the original explain 
string without the splitting?




-- 
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]


Reply via email to