Github user twalthr commented on a diff in the pull request:
https://github.com/apache/flink/pull/2653#discussion_r88493178
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/validate/FunctionCatalog.scala
---
@@ -47,13 +52,50 @@ class FunctionCatalog {
sqlFunctions += sqlFunction
}
+ /** Register multiple sql functions at one time. The functions has the
same name. **/
+ def registerSqlFunctions(functions: Seq[SqlFunction]): Unit = {
+ if (functions.nonEmpty) {
+ sqlFunctions --= sqlFunctions.filter(_.getName ==
functions.head.getName)
+ sqlFunctions ++= functions
+ }
+ }
+
def getSqlOperatorTable: SqlOperatorTable =
ChainedSqlOperatorTable.of(
new BasicOperatorTable(),
new ListSqlOperatorTable(sqlFunctions)
)
/**
+ * Lookup table function and create an TableFunctionCall if we find a
match.
+ */
+ def lookupTableFunction[T](name: String, children: Seq[Expression]):
TableFunctionCall[T] = {
+ val funcClass = functionBuilders
+ .getOrElse(name.toLowerCase, throw ValidationException(s"Undefined
function: $name"))
+ funcClass match {
+ // user-defined table function call
+ case tf if classOf[TableFunction[T]].isAssignableFrom(tf) =>
+
Try(UserDefinedFunctionUtils.instantiate(tf.asInstanceOf[Class[TableFunction[T]]]))
match {
+ case Success(tableFunction) => {
+ val clazz: Type = tableFunction.getClass.getGenericSuperclass
--- End diff --
As I said earlier this and following lines are very error-prone. We should
keep calls to the TypeExtractor to a very minimum. The TypeExtractor is only
intended for Java not Scala.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---