swuferhong commented on code in PR #20822:
URL: https://github.com/apache/flink/pull/20822#discussion_r1288271732


##########
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/plan/batch/sql/SubplanReuseTest.scala:
##########
@@ -334,6 +334,43 @@ class SubplanReuseTest extends TableTestBase {
     util.verifyExecPlan(sqlQuery)
   }
 
+  @Test
+  def testSubplanReuseOnSortedView(): Unit = {
+    util.addTableSource[(Int, Long, String, String, String)]("Source", 'a, 'b, 
'c, 'd, 'e)
+    val query = "SELECT * FROM Source order by d"
+    val table = util.tableEnv.sqlQuery(query)
+    // Define a sorted view.
+    util.tableEnv.createTemporaryView("SortedView", table)
+    util.tableEnv.executeSql("""
+                               |CREATE TABLE Sink1 (
+                               |   a int,
+                               |   b bigint,
+                               |   c string
+                               |) WITH (
+                               |   'connector' = 'filesystem',
+                               |   'format' = 'testcsv',
+                               |   'path' = '/tmp/test'
+                               |)
+                               |""".stripMargin)
+    util.tableEnv.executeSql("""
+                               |CREATE TABLE Sink2 (
+                               |   a int,
+                               |   b bigint,
+                               |   c string,
+                               |   d string
+                               |) WITH (
+                               |   'connector' = 'filesystem',
+                               |   'format' = 'testcsv',
+                               |   'path' = '/tmp/test'
+                               |)
+                               |""".stripMargin)
+    val stmtSet = util.tableEnv.createStatementSet()
+    stmtSet.addInsertSql("INSERT INTO Sink1 select a, b, e from SortedView")

Review Comment:
   > I think it's better to use the SQL in the jira to verify we have already 
fix this problem.
   
   Done!



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