[
https://issues.apache.org/jira/browse/FLINK-5776?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15885045#comment-15885045
]
ASF GitHub Bot commented on FLINK-5776:
---------------------------------------
Github user wuchong commented on a diff in the pull request:
https://github.com/apache/flink/pull/3418#discussion_r103127937
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/FlatMapRunner.scala
---
@@ -43,7 +45,15 @@ class FlatMapRunner[IN, OUT](
LOG.debug(s"Compiling FlatMapFunction: $name \n\n Code:\n$code")
val clazz = compile(getRuntimeContext.getUserCodeClassLoader, name,
code)
LOG.debug("Instantiating FlatMapFunction.")
- function = clazz.newInstance()
+ if (null == parameterValues || null == parameterTypes ||
+ parameterValues.length == 0 || parameterTypes.length == 0 ||
+ parameterTypes.length != parameterValues.length) {
--- End diff --
I think we do not need to check `parameterValues.length == 0`, if the
parameter length is 0, it also can be handled correctly by the `else` brach.
And also, I think we should not to check `parameterTypes.length !=
parameterValues.length`, in this case, a compile exception thrown would be
better rather than ignoring the parameters and using the 0-parameter
constructor.
So I think `null == parameterValues || null == parameterTypes` is enough
and simpler.
> Improve XXMapRunner support create instance by carrying constructor parameters
> ------------------------------------------------------------------------------
>
> Key: FLINK-5776
> URL: https://issues.apache.org/jira/browse/FLINK-5776
> Project: Flink
> Issue Type: Improvement
> Components: Table API & SQL
> Reporter: sunjincheng
> Assignee: sunjincheng
>
> At present, MapRunner FlatMapRunner only supports create non-parameter
> instance, but sometimes we need to carry constructor parameters to
> instantiate, so I would like to improve XXMapRunner support create instance
> by carrying constructor parameters.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)