[
https://issues.apache.org/jira/browse/FLINK-6196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15946752#comment-15946752
]
ASF GitHub Bot commented on FLINK-6196:
---------------------------------------
Github user KurtYoung commented on a diff in the pull request:
https://github.com/apache/flink/pull/3623#discussion_r108624761
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/functions/utils/UserDefinedFunctionUtils.scala
---
@@ -358,4 +366,116 @@ object UserDefinedFunctionUtils {
InstantiationUtil
.deserializeObject[UserDefinedFunction](byteData,
Thread.currentThread.getContextClassLoader)
}
+
+ /**
+ * Build a TableFunctionCall, a name and a sequence of params will
determine a unique
+ * [[TableFunctionCall]]
+ *
+ * @param name function name
+ * @param implicitResultType If no result type returned, it will use
this type.
+ * @param params The input expressions
+ * @return A unique [[TableFunctionCall]]
+ */
+ private[table] def buildTableFunctionCall(
+ name: String,
+ tableFunction: TableFunction[_],
+ implicitResultType: TypeInformation[_],
+ params: Expression*): TableFunctionCall = {
+ val arguments = expressionsToArguments(params: _*)
+ val userDefinedResultType = tableFunction.getResultType(arguments)
+ val resultType = {
+ if (userDefinedResultType != null) userDefinedResultType
+ else implicitResultType
+ }
+ TableFunctionCall(name, tableFunction, params, resultType)
+ }
+
+ /**
+ * Transform the expressions or rex nodes to Objects
+ * Only literal expressions will be passed, nulls for non-literal ones
+ *
+ * @param params actual parameters of the function
+ * @return A java List of the Objects
+ */
+ private[table] def expressionsToArguments(params: Expression*):
java.util.List[AnyRef] = {
--- End diff --
rename to transformLiteralExpresssions to better fits the purpose?
> 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)