Github user sunjincheng121 commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2653#discussion_r87314969
  
    --- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/TableEnvironment.scala
 ---
    @@ -152,21 +153,40 @@ abstract class TableEnvironment(val config: 
TableConfig) {
       protected def getBuiltInRuleSet: RuleSet
     
       /**
    -    * Registers a [[UserDefinedFunction]] under a unique name. Replaces 
already existing
    +    * Registers a [[ScalarFunction]] under a unique name. Replaces already 
existing
         * user-defined functions under this name.
         */
    -  def registerFunction(name: String, function: UserDefinedFunction): Unit 
= {
    -    function match {
    -      case sf: ScalarFunction =>
    -        // register in Table API
    -        functionCatalog.registerFunction(name, function.getClass)
    +  def registerFunction(name: String, function: ScalarFunction): Unit = {
    +    // register in Table API
    +    functionCatalog.registerFunction(name, function.getClass)
     
    -        // register in SQL API
    -        functionCatalog.registerSqlFunction(sf.getSqlFunction(name, 
typeFactory))
    +    // register in SQL API
    +    functionCatalog.registerSqlFunction(function.getSqlFunction(name, 
typeFactory))
    +  }
    +
    +  /**
    +    * Registers a [[TableFunction]] under a unique name. Replaces already 
existing
    +    * user-defined functions under this name.
    +    */
    +  private[flink] def registerTableFunctionInternal[T: TypeInformation](
    +    name: String, tf: TableFunction[T]): Unit = {
     
    -      case _ =>
    -        throw new TableException("Unsupported user-defined function type.")
    +    val typeInfo: TypeInformation[_] = if (tf.getResultType != null) {
    +      tf.getResultType
    +    } else {
    +      implicitly[TypeInformation[T]]
         }
    +
    +    val (fieldNames, fieldIndexes) = 
UserDefinedFunctionUtils.getFieldInfo(typeInfo)
    --- End diff --
    
    that’s good


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to