You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "lsyldliu (via GitHub)" <gi...@apache.org> on 2023/08/25 07:04:42 UTC

[GitHub] [flink] lsyldliu commented on a diff in pull request #23285: [FLINK-32952][table-planner] Fix scan reuse with readable metadata and watermark push down get wrong watermark error

lsyldliu commented on code in PR #23285:
URL: https://github.com/apache/flink/pull/23285#discussion_r1305266120


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/optimize/ScanReuseTest.java:
##########
@@ -324,4 +326,68 @@ public void testProjectReuseWithPartitionPushDown() {
             util.verifyExecPlan(sqlQuery);
         }
     }
+
+    @Test
+    public void testReuseWithReadMetadataAndWatermarkPushDown1() {
+        assumeTrue(isStreaming);
+        String ddl =
+                "CREATE TABLE MyTable1 (\n"
+                        + "  metadata_0 int METADATA VIRTUAL,\n"
+                        + "  a0 int,\n"
+                        + "  a1 int,\n"
+                        + "  ts STRING,\n "
+                        + "  rowtime as TO_TIMESTAMP(`ts`),\n"
+                        + "  WATERMARK FOR rowtime AS rowtime - INTERVAL '1' SECOND\n"
+                        + ") WITH (\n"
+                        + " 'connector' = 'values',\n"
+                        + " 'bounded' = 'false',\n"
+                        + " 'readable-metadata' = 'metadata_0:int',\n"
+                        + " 'enable-watermark-push-down' = 'true',\n"
+                        + " 'disable-lookup' = 'true'"
+                        + ")";
+        util.tableEnv().executeSql(ddl);
+
+        // join left side value source without projection spec.
+        String sqlQuery =
+                "SELECT T1.a0, T1.a1 FROM"
+                        + " (SELECT MIN(a0) as a0, MIN(a1) as a1, MIN(metadata_0) as metadata_0 "
+                        + " FROM MyTable1 GROUP BY"
+                        + " TUMBLE(rowtime, INTERVAL '1' SECOND)) T1,"
+                        + " (SELECT MIN(a0) as a0 FROM MyTable1 GROUP BY"
+                        + " TUMBLE(rowtime, INTERVAL '1' SECOND)) T2"

Review Comment:
   Tumble is deprecated, it would better use the new window tvf



##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/optimize/ScanReuseTest.java:
##########
@@ -324,4 +326,68 @@ public void testProjectReuseWithPartitionPushDown() {
             util.verifyExecPlan(sqlQuery);
         }
     }
+
+    @Test
+    public void testReuseWithReadMetadataAndWatermarkPushDown1() {
+        assumeTrue(isStreaming);
+        String ddl =
+                "CREATE TABLE MyTable1 (\n"
+                        + "  metadata_0 int METADATA VIRTUAL,\n"
+                        + "  a0 int,\n"
+                        + "  a1 int,\n"
+                        + "  ts STRING,\n "
+                        + "  rowtime as TO_TIMESTAMP(`ts`),\n"
+                        + "  WATERMARK FOR rowtime AS rowtime - INTERVAL '1' SECOND\n"
+                        + ") WITH (\n"
+                        + " 'connector' = 'values',\n"
+                        + " 'bounded' = 'false',\n"
+                        + " 'readable-metadata' = 'metadata_0:int',\n"
+                        + " 'enable-watermark-push-down' = 'true',\n"
+                        + " 'disable-lookup' = 'true'"
+                        + ")";
+        util.tableEnv().executeSql(ddl);
+
+        // join left side value source without projection spec.
+        String sqlQuery =
+                "SELECT T1.a0, T1.a1 FROM"
+                        + " (SELECT MIN(a0) as a0, MIN(a1) as a1, MIN(metadata_0) as metadata_0 "
+                        + " FROM MyTable1 GROUP BY"
+                        + " TUMBLE(rowtime, INTERVAL '1' SECOND)) T1,"
+                        + " (SELECT MIN(a0) as a0 FROM MyTable1 GROUP BY"
+                        + " TUMBLE(rowtime, INTERVAL '1' SECOND)) T2"
+                        + " WHERE T1.a0 = T2.a0";
+        util.verifyExecPlan(sqlQuery);
+    }
+
+    @Test
+    public void testReuseWithReadMetadataAndWatermarkPushDown2() {
+        assumeTrue(isStreaming);
+        String ddl =
+                "CREATE TABLE MyTable1 (\n"
+                        + "  metadata_0 int METADATA VIRTUAL,\n"
+                        + "  a0 int,\n"
+                        + "  a1 int,\n"
+                        + "  ts STRING,\n "
+                        + "  rowtime as TO_TIMESTAMP(`ts`),\n"
+                        + "  WATERMARK FOR rowtime AS rowtime - INTERVAL '1' SECOND\n"
+                        + ") WITH (\n"
+                        + " 'connector' = 'values',\n"
+                        + " 'bounded' = 'false',\n"
+                        + " 'readable-metadata' = 'metadata_0:int',\n"
+                        + " 'enable-watermark-push-down' = 'true',\n"
+                        + " 'disable-lookup' = 'true'"
+                        + ")";
+        util.tableEnv().executeSql(ddl);
+
+        // join right side value source without projection spec.
+        String sqlQuery =
+                "SELECT T1.a0, T2.a1 FROM"
+                        + " (SELECT MIN(a0) as a0 FROM MyTable1 GROUP BY"
+                        + " TUMBLE(rowtime, INTERVAL '1' SECOND)) T1,"
+                        + " (SELECT MIN(a0) as a0, MIN(a1) as a1, MIN(metadata_0) as metadata_0"
+                        + " FROM MyTable1 GROUP BY"
+                        + " TUMBLE(rowtime, INTERVAL '1' SECOND)) T2"

Review Comment:
   ditto



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

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