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

    https://github.com/apache/flink/pull/2653#discussion_r88336779
  
    --- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/functions/utils/UserDefinedFunctionUtils.scala
 ---
    @@ -162,24 +191,107 @@ object UserDefinedFunctionUtils {
       }
     
       /**
    +    * Internal method of [[ScalarFunction#getResultType()]] that does some 
pre-checking and uses
    +    * [[TypeExtractor]] as default return type inference.
    +    */
    +  def getResultType(
    +    tableFunction: TableFunction[_],
    +    signature: Array[Class[_]])
    +  : TypeInformation[_] = {
    +    // find method for signature
    +    val evalMethod = tableFunction.getEvalMethods
    +      .find(m => signature.sameElements(m.getParameterTypes))
    +      .getOrElse(throw new ValidationException("Given signature is 
invalid."))
    +
    +    val userDefinedTypeInfo = tableFunction.getResultType
    +    if (userDefinedTypeInfo != null) {
    +      userDefinedTypeInfo
    +    } else {
    +      try {
    +        TypeExtractor.getForClass(evalMethod.getReturnType)
    +      } catch {
    +        case ite: InvalidTypesException =>
    +          throw new ValidationException(
    +            s"Return type of table function '$this' cannot be " +
    +              s"automatically determined. Please provide type information 
manually.")
    +      }
    +    }
    +  }
    +
    +  /**
         * Returns the return type of the evaluation method matching the given 
signature.
         */
       def getResultTypeClass(
    -      scalarFunction: ScalarFunction,
    +      function: EvaluableFunction,
    --- End diff --
    
    I think `UserDefinedFunction` would be better.


---
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