Class ScalarFunctionImpl

java.lang.Object
org.apache.calcite.schema.impl.ReflectiveFunctionBase
org.apache.calcite.schema.impl.ScalarFunctionImpl
All Implemented Interfaces:
Function, ImplementableFunction, ScalarFunction

public class ScalarFunctionImpl extends ReflectiveFunctionBase implements ScalarFunction, ImplementableFunction
Implementation of ScalarFunction.
  • Method Details

    • createAll

      @Deprecated public static com.google.common.collect.ImmutableMultimap<String,ScalarFunction> createAll(Class<?> clazz)
      Deprecated.
      Creates ScalarFunction for each method in a given class.
    • functions

      public static com.google.common.collect.ImmutableMultimap<String,Function> functions(Class<?> clazz)
      Returns a map of all functions based on the methods in a given class. It is keyed by method names and maps to both ScalarFunction and TableFunction.
    • create

      public static @Nullable ScalarFunction create(Class<?> clazz, String methodName)
      Creates ScalarFunction from given class.

      If a method of the given name is not found, or it does not suit, returns null.

      Parameters:
      clazz - class that is used to implement the function
      methodName - Method name (typically "eval")
      Returns:
      created ScalarFunction or null
    • create

      public static ScalarFunction create(Method method)
      Creates ScalarFunction from given method. When eval method does not suit, null is returned.
      Parameters:
      method - method that is used to implement the function
      Returns:
      created ScalarFunction or null
    • createUnsafe

      public static ScalarFunction createUnsafe(Method method)
      Creates unsafe version of ScalarFunction from any method. The method does not need to be static or belong to a class with default constructor. It is the responsibility of the underlying engine to initialize the UDF object that contain the method.
      Parameters:
      method - method that is used to implement the function
    • getReturnType

      public RelDataType getReturnType(RelDataTypeFactory typeFactory)
      Description copied from interface: ScalarFunction
      Returns the return type of this function, constructed using the given type factory.
      Specified by:
      getReturnType in interface ScalarFunction
      Parameters:
      typeFactory - Type factory
    • getImplementor

      public CallImplementor getImplementor()
      Description copied from interface: ImplementableFunction
      Returns implementor that translates the function to linq4j expression.
      Specified by:
      getImplementor in interface ImplementableFunction
      Returns:
      implementor that translates the function to linq4j expression.
    • getReturnType

      public RelDataType getReturnType(RelDataTypeFactory typeFactory, SqlOperatorBinding opBinding)