matriv commented on a change in pull request #18401:
URL: https://github.com/apache/flink/pull/18401#discussion_r788064147



##########
File path: 
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/plan/utils/SetOpRewriteUtil.scala
##########
@@ -76,47 +69,24 @@ object SetOpRewriteUtil {
     * and the rest are the row fields.
     */
   def replicateRows(
-      builder: RelBuilder, outputType: RelDataType, fields: 
util.List[Integer]): RelNode = {
-    // construct LogicalTableFunctionScan
-    val logicalType = toLogicalRowType(outputType)
-    val fieldNames = outputType.getFieldNames.toSeq.toArray
-    val fieldTypes = 
logicalType.getChildren.map(fromLogicalTypeToTypeInfo).toArray
-    val tf = new ReplicateRows(fieldTypes)
-    val resultType = fromLegacyInfoToDataType(new RowTypeInfo(fieldTypes, 
fieldNames))
-    val function = new TypedFlinkTableFunction(tf, fieldNames, resultType)
-    val typeFactory = builder.getTypeFactory.asInstanceOf[FlinkTypeFactory]
-    val sqlFunction = new TableSqlFunction(
-      FunctionIdentifier.of(generateInlineFunctionName(tf)),
-      tf.toString,
-      tf,
-      resultType,
-      typeFactory,
-      function)
+      relBuilder: RelBuilder,
+      outputRelDataType: RelDataType,
+      fields: util.List[Integer]): RelNode = {
+    val cluster = relBuilder.getCluster
+
+    val sqlFunction = BridgingSqlFunction.of(
+      relBuilder.getCluster,
+      BuiltInFunctionDefinitions.INTERNAL_REPLICATE_ROWS)
 
-    val cluster = builder.peek().getCluster
-    // TODO use relBuilder.functionScan() once we remove TableSqlFunction
-    val scan = LogicalTableFunctionScan.create(
-      cluster,
-      new util.ArrayList[RelNode](),
-      builder.getRexBuilder
-        .makeCall(
-          function.getRowType(typeFactory),
-          sqlFunction,
-          builder.fields(Util.range(fields.size() + 1))),
-      function.getElementType(null),
-      UserDefinedFunctionUtils.buildRelDataType(
-        builder.getTypeFactory,
-        logicalType,
-        fieldNames,
-        fieldNames.indices.toArray),
-      null)
-    builder.push(scan)
+    relBuilder
+      .functionScan(sqlFunction, 0, relBuilder.fields(Util.range(fields.size() 
+ 1)))

Review comment:
       Thank you!
   




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