hequn8128 commented on a change in pull request #7196: [FLINK-10974] [table] 
Add support for flatMap to table API
URL: https://github.com/apache/flink/pull/7196#discussion_r272899748
 
 

 ##########
 File path: 
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/plan/OperationTreeBuilder.scala
 ##########
 @@ -376,6 +377,33 @@ class OperationTreeBuilder(private val tableEnv: 
TableEnvironment) {
     Project(expandedFields.map(UnresolvedAlias), childNode).validate(tableEnv)
   }
 
+  def flatMap(tableFunction: Expression, child: TableOperation): 
TableOperation = {
 
 Review comment:
   Maybe this method can be simplified as follows ?
   ```
     def flatMap(tableFunction: Expression, child: TableOperation): 
TableOperation = {
       val tableFuncWithoutAlias = getLeadingNonAliasExpr(tableFunction)
       val joinNode = joinLateral(child, tableFuncWithoutAlias, JoinType.INNER, 
Optional.empty())
       val dropNode = dropColumns(
         child.getTableSchema.getFieldNames.map(a => 
UnresolvedFieldReference(a)),
         joinNode)
   
       val temporalTable = UserDefinedFunctionUtils.createLogicalFunctionCall(
         expressionBridge.bridge(tableFunction),
         child.asInstanceOf[LogicalNode])
   
       alias(temporalTable.fieldNames.map(a => UnresolvedFieldReference(a)), 
dropNode)
     }
   ```
   Furthermore, we don't need the `extractTableFunction()` in 
`UserDefinedFunctionUtils` if we change the implementation to the above one. 
   What do you think?

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to