[
https://issues.apache.org/jira/browse/FLINK-6196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15974305#comment-15974305
]
ASF GitHub Bot commented on FLINK-6196:
---------------------------------------
Github user clarkyzl commented on a diff in the pull request:
https://github.com/apache/flink/pull/3623#discussion_r112141809
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/functions/utils/UserDefinedFunctionUtils.scala
---
@@ -382,7 +381,10 @@ object UserDefinedFunctionUtils {
implicitResultType: TypeInformation[_],
params: Expression*): TableFunctionCall = {
val arguments = transformLiteralExpressions(params: _*)
- val userDefinedResultType = tableFunction.getResultType(arguments)
+ val typeInformations = params.map { param =>
+ if (param.valid) param.resultType else null
--- End diff --
Actually. The `param.valid` here is to skip the `UnresolvedFieldReference`.
For example.
```
val result = in
.join(funcDyn('c, 1) as 'name)
.select('c, 'name)
```
will throw a `UnresolvedFieldReference`
```
org.apache.flink.table.api.UnresolvedException: Calling resultType on class
org.apache.flink.table.expressions.UnresolvedFieldReference.
at
org.apache.flink.table.expressions.UnresolvedFieldReference.resultType(fieldExpression.scala:45)
at
org.apache.flink.table.functions.utils.UserDefinedFunctionUtils$$anonfun$10.apply(UserDefinedFunctionUtils.scala:385)
at
org.apache.flink.table.functions.utils.UserDefinedFunctionUtils$$anonfun$10.apply(UserDefinedFunctionUtils.scala:384)
at
scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at
scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at
scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:34)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
at scala.collection.AbstractTraversable.map(Traversable.scala:105)
at
org.apache.flink.table.functions.utils.UserDefinedFunctionUtils$.buildTableFunctionCall(UserDefinedFunctionUtils.scala:384)
at
org.apache.flink.table.functions.TableFunction.apply(TableFunction.scala:91)
at
org.apache.flink.table.runtime.dataset.DataSetUserDefinedFunctionITCase.testDynamicSchema(DataSetUserDefinedFunctionITCase.scala:127)
```
Because `'c` is an `Expression` which has't been resolved.
> Support dynamic schema in Table Function
> ----------------------------------------
>
> Key: FLINK-6196
> URL: https://issues.apache.org/jira/browse/FLINK-6196
> Project: Flink
> Issue Type: Improvement
> Components: Table API & SQL
> Reporter: Zhuoluo Yang
> Assignee: Zhuoluo Yang
>
> In many of our use cases. We have to decide the schema of a UDTF at the run
> time. For example. udtf('c1, c2, c3') will generate three columns for a
> lateral view.
> Most systems such as calcite and hive support this feature. However, the
> current implementation of flink didn't implement the feature correctly.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)