godfreyhe commented on a change in pull request #9141: [FLINK-12249][table] Fix 
type equivalence check problems for Window Aggregates
URL: https://github.com/apache/flink/pull/9141#discussion_r306725608
 
 

 ##########
 File path: 
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/rules/logical/LogicalWindowAggregateRuleBase.scala
 ##########
 @@ -111,12 +120,75 @@ abstract class 
LogicalWindowAggregateRuleBase(description: String)
     // The transformation adds an additional LogicalProject at the top to 
ensure
     // that the types are equivalent.
     transformed.push(windowAgg)
-      .project(transformed.fields().patch(windowExprIdx, 
Seq(outAggGroupExpression), 0))
+      .project(transformed
+        .fields()
+        .patch(windowExprIdx, Seq(outAggGroupExpression), 0)
+        .zipWithIndex.map { rexNodeAndIndex =>
+        val aggCallIndex = rexNodeAndIndex._2 - agg.getGroupCount
+        if (indexAndTypes.containsKey(aggCallIndex)) {
+          rexBuilder.makeCast(agg.getAggCallList.get(aggCallIndex).`type`, 
rexNodeAndIndex._1, true)
+        } else {
+          rexNodeAndIndex._1
+        }
+      })
 
     val result = transformed.build()
     call.transformTo(result)
   }
 
+  /**
+    * Change the types of [[AggregateCall]] to the corresponding inferred 
types.
+    */
+  private def replaceAggCalls(
+    indexAndTypes: Map[Int, RelDataType], agg: LogicalAggregate): 
Seq[AggregateCall] = {
+
+    agg.getAggCallList.zipWithIndex.map { aggCallAndIndex =>
 
 Review comment:
   nit: map {
   case (aggCall, index) =>
   ...
   } 
   

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


With regards,
Apache Git Services

Reply via email to