|
17 | 17 | */ |
18 | 18 | package org.apache.flink.table.planner.codegen |
19 | 19 |
|
20 | | -import org.apache.flink.api.common.functions.{FlatMapFunction, Function, OpenContext} |
| 20 | +import org.apache.flink.api.common.functions.{FlatMapFunction, OpenContext} |
21 | 21 | import org.apache.flink.configuration.ReadableConfig |
22 | 22 | import org.apache.flink.streaming.api.functions.async.AsyncFunction |
23 | 23 | import org.apache.flink.table.api.ValidationException |
24 | 24 | import org.apache.flink.table.catalog.DataTypeFactory |
25 | 25 | import org.apache.flink.table.connector.source.{LookupTableSource, ScanTableSource} |
26 | 26 | import org.apache.flink.table.data.{GenericRowData, RowData} |
27 | 27 | import org.apache.flink.table.data.utils.JoinedRowData |
28 | | -import org.apache.flink.table.functions.{AsyncLookupFunction, AsyncPredictFunction, AsyncTableFunction, LookupFunction, PredictFunction, TableFunction, UserDefinedFunction, UserDefinedFunctionHelper} |
| 28 | +import org.apache.flink.table.functions.{AsyncLookupFunction, AsyncTableFunction, LookupFunction, TableFunction, UserDefinedFunction} |
29 | 29 | import org.apache.flink.table.planner.calcite.FlinkTypeFactory |
30 | 30 | import org.apache.flink.table.planner.codegen.CodeGenUtils._ |
31 | 31 | import org.apache.flink.table.planner.codegen.FunctionCallCodeGenerator.GeneratedTableFunctionWithDataType |
32 | | -import org.apache.flink.table.planner.codegen.GenerateUtils._ |
33 | 32 | import org.apache.flink.table.planner.codegen.Indenter.toISC |
34 | | -import org.apache.flink.table.planner.codegen.LookupJoinCodeGenerator.generateCallWithDataType |
35 | 33 | import org.apache.flink.table.planner.codegen.calls.BridgingFunctionGenUtil |
36 | 34 | import org.apache.flink.table.planner.codegen.calls.BridgingFunctionGenUtil.verifyFunctionAwareImplementation |
37 | | -import org.apache.flink.table.planner.delegation.PlannerBase |
38 | 35 | import org.apache.flink.table.planner.functions.inference.FunctionCallContext |
39 | | -import org.apache.flink.table.planner.plan.utils.FunctionCallUtil.{Constant, FieldRef, FunctionParam} |
40 | | -import org.apache.flink.table.planner.plan.utils.RexLiteralUtil |
| 36 | +import org.apache.flink.table.planner.plan.utils.FunctionCallUtil.FunctionParam |
41 | 37 | import org.apache.flink.table.planner.utils.JavaScalaConversionUtil.toScala |
42 | 38 | import org.apache.flink.table.runtime.collector.{ListenableCollector, TableFunctionResultFuture} |
43 | 39 | import org.apache.flink.table.runtime.collector.ListenableCollector.CollectListener |
@@ -238,138 +234,6 @@ object LookupJoinCodeGenerator { |
238 | 234 | } |
239 | 235 | } |
240 | 236 |
|
241 | | - /** |
242 | | - * Generates collector for temporal join ([[Collector]]) |
243 | | - * |
244 | | - * Differs from CommonCorrelate.generateCollector which has no real condition because of |
245 | | - * FLINK-7865, here we should deal with outer join type when real conditions filtered result. |
246 | | - */ |
247 | | - def generateCollector( |
248 | | - ctx: CodeGeneratorContext, |
249 | | - inputRowType: RowType, |
250 | | - rightRowType: RowType, |
251 | | - resultRowType: RowType, |
252 | | - condition: Option[RexNode], |
253 | | - pojoFieldMapping: Option[Array[Int]], |
254 | | - retainHeader: Boolean = true): GeneratedCollector[ListenableCollector[RowData]] = { |
255 | | - |
256 | | - val inputTerm = DEFAULT_INPUT1_TERM |
257 | | - val rightInputTerm = DEFAULT_INPUT2_TERM |
258 | | - |
259 | | - val exprGenerator = new ExprCodeGenerator(ctx, nullableInput = false) |
260 | | - .bindInput(rightRowType, inputTerm = rightInputTerm, inputFieldMapping = pojoFieldMapping) |
261 | | - |
262 | | - val rightResultExpr = |
263 | | - exprGenerator.generateConverterResultExpression(rightRowType, classOf[GenericRowData]) |
264 | | - |
265 | | - val joinedRowTerm = CodeGenUtils.newName(ctx, "joinedRow") |
266 | | - ctx.addReusableOutputRecord(resultRowType, classOf[JoinedRowData], joinedRowTerm) |
267 | | - |
268 | | - val header = if (retainHeader) { |
269 | | - s"$joinedRowTerm.setRowKind($inputTerm.getRowKind());" |
270 | | - } else { |
271 | | - "" |
272 | | - } |
273 | | - |
274 | | - val body = |
275 | | - s""" |
276 | | - |${rightResultExpr.code} |
277 | | - |$joinedRowTerm.replace($inputTerm, ${rightResultExpr.resultTerm}); |
278 | | - |$header |
279 | | - |outputResult($joinedRowTerm); |
280 | | - """.stripMargin |
281 | | - |
282 | | - val collectorCode = if (condition.isEmpty) { |
283 | | - body |
284 | | - } else { |
285 | | - |
286 | | - val filterGenerator = new ExprCodeGenerator(ctx, nullableInput = false) |
287 | | - .bindInput(inputRowType, inputTerm) |
288 | | - .bindSecondInput(rightRowType, rightInputTerm, pojoFieldMapping) |
289 | | - val filterCondition = filterGenerator.generateExpression(condition.get) |
290 | | - |
291 | | - s""" |
292 | | - |${filterCondition.code} |
293 | | - |if (${filterCondition.resultTerm}) { |
294 | | - | $body |
295 | | - |} |
296 | | - |""".stripMargin |
297 | | - } |
298 | | - |
299 | | - generateTableFunctionCollectorForJoinTable( |
300 | | - ctx, |
301 | | - "JoinTableFuncCollector", |
302 | | - collectorCode, |
303 | | - inputRowType, |
304 | | - rightRowType, |
305 | | - inputTerm = inputTerm, |
306 | | - collectedTerm = rightInputTerm) |
307 | | - } |
308 | | - |
309 | | - /** |
310 | | - * The only differences against CollectorCodeGenerator.generateTableFunctionCollector is |
311 | | - * "super.collect" call is binding with collect join row in "body" code |
312 | | - */ |
313 | | - private def generateTableFunctionCollectorForJoinTable( |
314 | | - ctx: CodeGeneratorContext, |
315 | | - name: String, |
316 | | - bodyCode: String, |
317 | | - inputType: RowType, |
318 | | - collectedType: RowType, |
319 | | - inputTerm: String = DEFAULT_INPUT1_TERM, |
320 | | - collectedTerm: String = DEFAULT_INPUT2_TERM) |
321 | | - : GeneratedCollector[ListenableCollector[RowData]] = { |
322 | | - |
323 | | - val funcName = newName(ctx, name) |
324 | | - val input1TypeClass = boxedTypeTermForType(inputType) |
325 | | - val input2TypeClass = boxedTypeTermForType(collectedType) |
326 | | - |
327 | | - val funcCode = |
328 | | - s""" |
329 | | - public class $funcName extends ${classOf[ListenableCollector[_]].getCanonicalName} { |
330 | | - |
331 | | - ${ctx.reuseMemberCode()} |
332 | | - |
333 | | - public $funcName(Object[] references) throws Exception { |
334 | | - ${ctx.reuseInitCode()} |
335 | | - } |
336 | | - |
337 | | - @Override |
338 | | - public void open(${className[OpenContext]} openContext) throws Exception { |
339 | | - ${ctx.reuseOpenCode()} |
340 | | - } |
341 | | - |
342 | | - @Override |
343 | | - public void collect(Object record) throws Exception { |
344 | | - $input1TypeClass $inputTerm = ($input1TypeClass) getInput(); |
345 | | - $input2TypeClass $collectedTerm = ($input2TypeClass) record; |
346 | | - |
347 | | - // callback only when collectListener exists, equivalent to: |
348 | | - // getCollectListener().ifPresent( |
349 | | - // listener -> ((CollectListener) listener).onCollect(record)); |
350 | | - // TODO we should update code splitter's grammar file to accept lambda expressions. |
351 | | - |
352 | | - if (getCollectListener().isPresent()) { |
353 | | - ((${classOf[CollectListener[_]].getCanonicalName}) getCollectListener().get()) |
354 | | - .onCollect(record); |
355 | | - } |
356 | | - |
357 | | - ${ctx.reuseLocalVariableCode()} |
358 | | - ${ctx.reuseInputUnboxingCode()} |
359 | | - ${ctx.reusePerRecordCode()} |
360 | | - $bodyCode |
361 | | - } |
362 | | - |
363 | | - @Override |
364 | | - public void close() throws Exception { |
365 | | - ${ctx.reuseCloseCode()} |
366 | | - } |
367 | | - } |
368 | | - """.stripMargin |
369 | | - |
370 | | - new GeneratedCollector(funcName, funcCode, ctx.references.toArray, ctx.tableConfig) |
371 | | - } |
372 | | - |
373 | 237 | /** |
374 | 238 | * Generates a [[TableFunctionResultFuture]] that can be passed to Java compiler. |
375 | 239 | * |
|
0 commit comments