public class UserDefinedFunctionUtils extends Object
Constructor and Description |
---|
UserDefinedFunctionUtils() |
Modifier and Type | Method and Description |
---|---|
static Method[] |
checkAndExtractMethods(UserDefinedFunction function,
String methodName)
Extracts methods and throws a
ValidationException if no implementation
can be found, or implementation does not match the requirements. |
static void |
checkForInstantiation(Class<?> clazz)
Checks if a user-defined function can be easily instantiated.
|
static void |
checkNotSingleton(Class<?> clazz)
Check whether this is a Scala object.
|
static org.apache.calcite.sql.SqlFunction |
createAggregateSqlFunction(String name,
AggregateFunction<?,?> aggFunction,
TypeInformation<?> typeInfo,
FlinkTypeFactory typeFactory)
Create
SqlFunction for an AggregateFunction |
static LogicalTableFunctionCall |
createLogicalFunctionCall(TableEnvironment tableEnv,
String udtf)
Creates a
LogicalTableFunctionCall by parsing a String expression. |
static org.apache.calcite.sql.SqlFunction |
createScalarSqlFunction(String name,
ScalarFunction function,
FlinkTypeFactory typeFactory)
Create
SqlFunction for a ScalarFunction |
static scala.collection.Seq<org.apache.calcite.sql.SqlFunction> |
createTableSqlFunctions(String name,
TableFunction<?> tableFunction,
TypeInformation<?> resultType,
FlinkTypeFactory typeFactory)
Create
SqlFunction s for a TableFunction 's every eval method |
static UserDefinedFunction |
deserialize(String data) |
static scala.Option<Class<?>[]> |
getAccumulateMethodSignature(AggregateFunction<?,?> function,
scala.collection.Seq<TypeInformation<?>> signature)
Returns signatures of accumulate methods matching the given signature of
TypeInformation . |
static scala.Option<Class<?>[]> |
getEvalMethodSignature(UserDefinedFunction function,
scala.collection.Seq<TypeInformation<?>> signature)
Returns signatures of eval methods matching the given signature of
TypeInformation . |
static scala.Tuple3<String[],int[],TypeInformation<?>[]> |
getFieldInfo(TypeInformation<?> inputType)
Returns field names and field positions for a given
TypeInformation . |
static Class<?>[][] |
getMethodSignatures(UserDefinedFunction function,
String methodName) |
static scala.collection.Seq<TypeInformation<?>> |
getOperandTypeInfo(org.apache.calcite.sql.SqlCallBinding callBinding) |
static TypeInformation<?>[] |
getParameterTypes(UserDefinedFunction function,
Class<?>[] signature) |
static Class<?> |
getResultTypeClassOfScalarFunction(ScalarFunction function,
Class<?>[] signature)
Returns the return type of the evaluation method matching the given signature.
|
static TypeInformation<?> |
getResultTypeOfAggregateFunction(AggregateFunction<?,?> aggregateFunction,
TypeInformation<?> extractedType)
Internal method of AggregateFunction#getResultType() that does some pre-checking and uses
TypeExtractor as default return type inference. |
static TypeInformation<?> |
getResultTypeOfScalarFunction(ScalarFunction function,
Class<?>[] signature)
Internal method of
ScalarFunction#getResultType() that does some pre-checking and uses
TypeExtractor as default return type inference. |
static scala.Option<Method> |
getUserDefinedMethod(UserDefinedFunction function,
String methodName,
Class<?>[] methodSignature)
Returns user defined method matching the given name and signature.
|
static boolean |
ifMethodExistInFunction(String method,
UserDefinedFunction function)
Check if a given method exists in the given function
|
static String |
serialize(UserDefinedFunction function) |
static String |
signaturesToString(UserDefinedFunction function,
String name)
Prints all signatures of methods with given name in a class.
|
static String |
signatureToString(Class<?>[] signature)
Prints one signature consisting of classes.
|
static String |
signatureToString(scala.collection.Seq<TypeInformation<?>> signature)
Prints one signature consisting of TypeInformation.
|
static Class<?>[] |
typeInfoToClass(scala.collection.Seq<TypeInformation<?>> typeInfos)
Extracts type classes of
TypeInformation in a null-aware way. |
public static void checkForInstantiation(Class<?> clazz)
clazz
- (undocumented)public static void checkNotSingleton(Class<?> clazz)
TableFunction
implemented
by a Scala object, since concurrent risks.clazz
- (undocumented)public static scala.Option<Class<?>[]> getEvalMethodSignature(UserDefinedFunction function, scala.collection.Seq<TypeInformation<?>> signature)
TypeInformation
.
Elements of the signature can be null (act as a wildcard).function
- (undocumented)signature
- (undocumented)public static scala.Option<Class<?>[]> getAccumulateMethodSignature(AggregateFunction<?,?> function, scala.collection.Seq<TypeInformation<?>> signature)
TypeInformation
.
Elements of the signature can be null (act as a wildcard).function
- (undocumented)signature
- (undocumented)public static TypeInformation<?>[] getParameterTypes(UserDefinedFunction function, Class<?>[] signature)
public static scala.Option<Method> getUserDefinedMethod(UserDefinedFunction function, String methodName, Class<?>[] methodSignature)
function
- function instancemethodName
- method namemethodSignature
- an array of raw Java classes. We compare the raw Java classes not the
TypeInformation. TypeInformation does not matter during runtime (e.g.
within a MapFunction)public static boolean ifMethodExistInFunction(String method, UserDefinedFunction function)
method
- (undocumented)function
- (undocumented)public static Method[] checkAndExtractMethods(UserDefinedFunction function, String methodName)
ValidationException
if no implementation
can be found, or implementation does not match the requirements.function
- (undocumented)methodName
- (undocumented)public static Class<?>[][] getMethodSignatures(UserDefinedFunction function, String methodName)
public static org.apache.calcite.sql.SqlFunction createScalarSqlFunction(String name, ScalarFunction function, FlinkTypeFactory typeFactory)
SqlFunction
for a ScalarFunction
name
- function namefunction
- scalar functiontypeFactory
- type factorypublic static scala.collection.Seq<org.apache.calcite.sql.SqlFunction> createTableSqlFunctions(String name, TableFunction<?> tableFunction, TypeInformation<?> resultType, FlinkTypeFactory typeFactory)
SqlFunction
s for a TableFunction
's every eval method
name
- function nametableFunction
- table functionresultType
- the type information of returned tabletypeFactory
- type factorypublic static org.apache.calcite.sql.SqlFunction createAggregateSqlFunction(String name, AggregateFunction<?,?> aggFunction, TypeInformation<?> typeInfo, FlinkTypeFactory typeFactory)
SqlFunction
for an AggregateFunction
name
- function nameaggFunction
- aggregate functiontypeFactory
- type factorytypeInfo
- (undocumented)public static TypeInformation<?> getResultTypeOfAggregateFunction(AggregateFunction<?,?> aggregateFunction, TypeInformation<?> extractedType)
TypeExtractor
as default return type inference.aggregateFunction
- (undocumented)extractedType
- (undocumented)public static TypeInformation<?> getResultTypeOfScalarFunction(ScalarFunction function, Class<?>[] signature)
ScalarFunction#getResultType()
that does some pre-checking and uses
TypeExtractor
as default return type inference.function
- (undocumented)signature
- (undocumented)public static Class<?> getResultTypeClassOfScalarFunction(ScalarFunction function, Class<?>[] signature)
function
- (undocumented)signature
- (undocumented)public static scala.Tuple3<String[],int[],TypeInformation<?>[]> getFieldInfo(TypeInformation<?> inputType)
TypeInformation
.
Field names are automatically extracted for
CompositeType
.
inputType
- The TypeInformation to extract the field names and positions from.public static String signatureToString(Class<?>[] signature)
signature
- (undocumented)public static String signatureToString(scala.collection.Seq<TypeInformation<?>> signature)
signature
- (undocumented)public static String signaturesToString(UserDefinedFunction function, String name)
function
- (undocumented)name
- (undocumented)public static Class<?>[] typeInfoToClass(scala.collection.Seq<TypeInformation<?>> typeInfos)
TypeInformation
in a null-aware way.typeInfos
- (undocumented)public static String serialize(UserDefinedFunction function) throws Exception
Exception
public static UserDefinedFunction deserialize(String data) throws Exception
Exception
public static LogicalTableFunctionCall createLogicalFunctionCall(TableEnvironment tableEnv, String udtf)
LogicalTableFunctionCall
by parsing a String expression.
tableEnv
- The table environmenent to lookup the function.udtf
- a String expression of a TableFunctionCall, such as "split(c)"public static scala.collection.Seq<TypeInformation<?>> getOperandTypeInfo(org.apache.calcite.sql.SqlCallBinding callBinding)
Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.