Class UserDefinedFunctionHelper


  • @Internal
    public final class UserDefinedFunctionHelper
    extends Object
    Utility for dealing with subclasses of UserDefinedFunction. The purpose of this class is to keep the user-facing APIs clean and offer methods/constants from here.

    It contains methods for instantiating, validating and extracting types during function registration in a catalog.

    • Method Detail

      • getReturnTypeOfAggregateFunction

        public static <T,​ACC> TypeInformation<T> getReturnTypeOfAggregateFunction​(ImperativeAggregateFunction<T,​ACC> aggregateFunction)
        Tries to infer the TypeInformation of an AggregateFunction's accumulator type.
        Parameters:
        aggregateFunction - The AggregateFunction for which the accumulator type is inferred.
        Returns:
        The inferred accumulator type of the AggregateFunction.
      • getReturnTypeOfAggregateFunction

        public static <T,​ACC> TypeInformation<T> getReturnTypeOfAggregateFunction​(ImperativeAggregateFunction<T,​ACC> aggregateFunction,
                                                                                        TypeInformation<T> scalaType)
        Tries to infer the TypeInformation of an AggregateFunction's accumulator type.
        Parameters:
        aggregateFunction - The AggregateFunction for which the accumulator type is inferred.
        scalaType - The implicitly inferred type of the accumulator type.
        Returns:
        The inferred accumulator type of the AggregateFunction.
      • getAccumulatorTypeOfAggregateFunction

        public static <T,​ACC> TypeInformation<ACC> getAccumulatorTypeOfAggregateFunction​(ImperativeAggregateFunction<T,​ACC> aggregateFunction)
        Tries to infer the TypeInformation of an AggregateFunction's accumulator type.
        Parameters:
        aggregateFunction - The AggregateFunction for which the accumulator type is inferred.
        Returns:
        The inferred accumulator type of the AggregateFunction.
      • getAccumulatorTypeOfAggregateFunction

        public static <T,​ACC> TypeInformation<ACC> getAccumulatorTypeOfAggregateFunction​(ImperativeAggregateFunction<T,​ACC> aggregateFunction,
                                                                                               TypeInformation<ACC> scalaType)
        Tries to infer the TypeInformation of an AggregateFunction's accumulator type.
        Parameters:
        aggregateFunction - The AggregateFunction for which the accumulator type is inferred.
        scalaType - The implicitly inferred type of the accumulator type.
        Returns:
        The inferred accumulator type of the AggregateFunction.
      • getReturnTypeOfTableFunction

        public static <T> TypeInformation<T> getReturnTypeOfTableFunction​(TableFunction<T> tableFunction)
        Tries to infer the TypeInformation of an AggregateFunction's accumulator type.
        Parameters:
        tableFunction - The TableFunction for which the accumulator type is inferred.
        Returns:
        The inferred accumulator type of the AggregateFunction.
      • getReturnTypeOfTableFunction

        public static <T> TypeInformation<T> getReturnTypeOfTableFunction​(TableFunction<T> tableFunction,
                                                                          TypeInformation<T> scalaType)
        Tries to infer the TypeInformation of an AggregateFunction's accumulator type.
        Parameters:
        tableFunction - The TableFunction for which the accumulator type is inferred.
        scalaType - The implicitly inferred type of the accumulator type.
        Returns:
        The inferred accumulator type of the AggregateFunction.
      • generateInlineFunctionName

        public static String generateInlineFunctionName​(UserDefinedFunction function)
        Name for anonymous, inline functions.
      • validateClass

        public static void validateClass​(Class<? extends UserDefinedFunction> functionClass)
        Validates a UserDefinedFunction class for usage in the API.

        Note: This is an initial validation to indicate common errors early. The concrete signature validation happens in the code generation when the actual DataTypes for arguments and result are known.

      • validateClassForRuntime

        public static void validateClassForRuntime​(Class<? extends UserDefinedFunction> functionClass,
                                                   String methodName,
                                                   Class<?>[] argumentClasses,
                                                   Class<?> outputClass,
                                                   String functionName)
        Validates a UserDefinedFunction class for usage in the runtime.

        Note: This is for the final validation when actual DataTypes for arguments and result are known.