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



##########
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:
       OK

##########
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:
       OK




-- 
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...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to