jnh5y commented on code in PR #25316:
URL: https://github.com/apache/flink/pull/25316#discussion_r1830289157


##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/calcite/SqlRewriterUtils.scala:
##########
@@ -193,11 +193,33 @@ object SqlRewriterUtils {
     // Expands the select list first in case there is a star(*).
     // Validates the select first to register the where scope.
     validator.validate(cte)
-    val select = cte.body.asInstanceOf[SqlSelect];
-    reorderAndValidateForSelect(validator, select, targetRowType, 
assignedFields, targetPosition)
+    val selects = new util.ArrayList[SqlSelect]()
+    extractSelectsFromCte(cte.body.asInstanceOf[SqlCall], selects)
+
+    for (select <- selects) {
+      reorderAndValidateForSelect(validator, select, targetRowType, 
assignedFields, targetPosition)
+    }
     cte
   }
 
+  def extractSelectsFromCte(cte: SqlCall, selects: util.List[SqlSelect]): Unit 
= {

Review Comment:
   Nice!  
   
   I kinda don't like that `selects` is passed in instead of returned.  I tried 
refactoring it, but it doesn't look much better.  



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