JingsongLi commented on a change in pull request #14977:
URL: https://github.com/apache/flink/pull/14977#discussion_r591213360



##########
File path: 
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/calcite/PreValidateReWriter.scala
##########
@@ -191,41 +267,40 @@ object PreValidateReWriter {
     SqlStdOperatorTable.VALUES.createCall(values.getParserPosition, fixedNodes)
   }
 
+  private def reorder(
+      sourceList: util.ArrayList[SqlNode],
+      targetPosition: util.List[Int]): util.ArrayList[SqlNode] = {
+    val targetList = new Array[SqlNode](sourceList.size())
+    0 until sourceList.size() foreach {
+      idx => targetList(targetPosition.get(idx)) = sourceList.get(idx)

Review comment:
       ```
   @Test
     def testPartialInsertWithComplexReorder(): Unit = {
       tEnv.executeSql(
         s"""
            |CREATE TABLE testSink (
            |  `a` INT,
            |  `c` STRING,
            |  `c1` STRING,
            |  `c2` STRING,
            |  `c3` BIGINT,
            |  `d` INT,
            |  `e` DOUBLE
            |)
            |WITH (
            |  'connector' = 'values',
            |  'sink-insert-only' = 'false'
            |)
            |""".stripMargin)
   
       val t = env.fromCollection(tupleData2).toTable(tEnv, 'x, 'y)
       tEnv.createTemporaryView("MyTable", t)
   
       tEnv.executeSql(
         s"""
            |INSERT INTO testSink (a,c2,e,c,c1,c3,d)
            |SELECT 1,'c2',sum(y),'c','c1',33333,12 FROM MyTable GROUP BY x
            |""".stripMargin).await()
       val expected = List(
         "1,c,c1,c2,33333,12,0.1",
         "1,c,c1,c2,33333,12,0.4",
         "1,c,c1,c2,33333,12,1.0",
         "1,c,c1,c2,33333,12,2.2",
         "1,c,c1,c2,33333,12,3.9")
       val result = TestValuesTableFactory.getResults("testSink")
       assertEquals(expected.sorted, result.sorted)
     }
   ```




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


Reply via email to