public final class FunctionRegistry extends Object
Modifier and Type | Field and Description |
---|---|
static Set<String> |
HIVE_OPERATORS |
static String |
LAG_FUNC_NAME |
static String |
LAST_VALUE_FUNC_NAME |
static String |
LEAD_FUNC_NAME |
static String |
UNARY_MINUS_FUNC_NAME |
static String |
UNARY_PLUS_FUNC_NAME |
static String |
WINDOWING_TABLE_FUNCTION |
Modifier and Type | Method and Description |
---|---|
static GenericUDF |
cloneGenericUDF(GenericUDF genericUDF)
Create a copy of an existing GenericUDF.
|
static GenericUDTF |
cloneGenericUDTF(GenericUDTF genericUDTF)
Create a copy of an existing GenericUDTF.
|
static PrimitiveObjectInspector.PrimitiveCategory |
getCommonCategory(TypeInfo a,
TypeInfo b) |
static TypeInfo |
getCommonClass(TypeInfo a,
TypeInfo b)
Find a common class that objects of both TypeInfo a and TypeInfo b can
convert to.
|
static TypeInfo |
getCommonClassForComparison(TypeInfo a,
TypeInfo b)
Find a common class that objects of both TypeInfo a and TypeInfo b can
convert to.
|
static TypeInfo |
getCommonClassForUnionAll(TypeInfo a,
TypeInfo b)
Find a common class for union-all operator
|
static FunctionInfo |
getFunctionInfo(String functionName) |
static Set<String> |
getFunctionNames() |
static Set<String> |
getFunctionNames(String funcPatternStr) |
static Set<String> |
getFunctionNamesByLikePattern(String funcPatternStr)
Returns a set of registered function names which matchs the given pattern.
|
static Set<String> |
getFunctionSynonyms(String funcName)
Returns the set of synonyms of the supplied function.
|
static GenericUDAFEvaluator |
getGenericUDAFEvaluator(String name,
List<ObjectInspector> argumentOIs,
boolean isDistinct,
boolean isAllColumns)
Get the GenericUDAF evaluator for the name and argumentClasses.
|
static GenericUDAFResolver |
getGenericUDAFResolver(String functionName) |
static GenericUDF |
getGenericUDFForAnd()
A shortcut to get the "and" GenericUDF.
|
static GenericUDF |
getGenericUDFForIndex()
A shortcut to get the "index" GenericUDF.
|
static GenericUDAFEvaluator |
getGenericWindowingEvaluator(String name,
List<ObjectInspector> argumentOIs,
boolean isDistinct,
boolean isAllColumns) |
static Method |
getMethodInternal(Class<?> udfClass,
List<Method> mlist,
boolean exact,
List<TypeInfo> argumentsPassed)
Gets the closest matching method corresponding to the argument list from a
list of methods.
|
static <T> Method |
getMethodInternal(Class<? extends T> udfClass,
String methodName,
boolean exact,
List<TypeInfo> argumentClasses)
This method is shared between UDFRegistry and UDAFRegistry.
|
static String |
getNormalizedFunctionName(String fn) |
static TableFunctionResolver |
getTableFunctionResolver(String functionName) |
static FunctionInfo |
getTemporaryFunctionInfo(String functionName) |
static TypeInfo |
getTypeInfoForPrimitiveCategory(PrimitiveTypeInfo a,
PrimitiveTypeInfo b,
PrimitiveObjectInspector.PrimitiveCategory typeCategory)
Given 2 TypeInfo types and the PrimitiveCategory selected as the common class between the two,
return a TypeInfo corresponding to the common PrimitiveCategory, and with type qualifiers
(if applicable) that match the 2 TypeInfo types.
|
static WindowFunctionInfo |
getWindowFunctionInfo(String functionName) |
static TableFunctionResolver |
getWindowingTableFunction() |
static boolean |
implicitConvertible(PrimitiveObjectInspector.PrimitiveCategory from,
PrimitiveObjectInspector.PrimitiveCategory to) |
static boolean |
implicitConvertible(TypeInfo from,
TypeInfo to)
Returns whether it is possible to implicitly convert an object of Class
from to Class to.
|
static boolean |
impliesOrder(String functionName)
Both UDF and UDAF functions can imply order for analytical functions
|
static Object |
invoke(Method m,
Object thisObject,
Object... arguments) |
static boolean |
isBuiltInFuncExpr(ExprNodeGenericFuncDesc fnExpr) |
static boolean |
isDeterministic(GenericUDF genericUDF)
Returns whether a GenericUDF is deterministic or not.
|
static boolean |
isExactNumericType(PrimitiveTypeInfo typeInfo)
Check if a type is exact (not approximate such as float and double).
|
static boolean |
isNoopFunction(String fnName) |
static boolean |
isNumericType(PrimitiveTypeInfo typeInfo)
Check if the given type is numeric.
|
static boolean |
isOpAnd(ExprNodeDesc desc)
Returns whether the exprNodeDesc is a node of "and".
|
static boolean |
isOpAndOrNot(ExprNodeDesc desc)
Returns whether the exprNodeDesc is a node of "and", "or", "not".
|
static boolean |
isOpCast(ExprNodeDesc desc)
Returns whether the exprNodeDesc is node of "cast".
|
static boolean |
isOpCast(GenericUDF genericUDF) |
static boolean |
isOpNot(ExprNodeDesc desc)
Returns whether the exprNodeDesc is a node of "not".
|
static boolean |
isOpOr(ExprNodeDesc desc)
Returns whether the exprNodeDesc is a node of "or".
|
static boolean |
isOpPositive(ExprNodeDesc desc)
Returns whether the exprNodeDesc is a node of "positive".
|
static boolean |
isOpPreserveInputName(ExprNodeDesc desc)
Returns whether the exprNodeDesc can recommend name for the expression
|
static boolean |
isRankingFunction(String name)
Use this to check if function is ranking function
|
static boolean |
isStateful(GenericUDF genericUDF)
Returns whether a GenericUDF is stateful or not.
|
static boolean |
isTableFunction(String functionName) |
static int |
matchCost(TypeInfo argumentPassed,
TypeInfo argumentAccepted,
boolean exact)
Returns -1 if passed does not match accepted.
|
static boolean |
pivotResult(String functionName) |
static FunctionInfo |
registerPermanentFunction(String functionName,
String className,
boolean registerToSession,
FunctionInfo.FunctionResource[] resources) |
static void |
registerTemporaryMacro(String macroName,
ExprNodeDesc body,
List<String> colNames,
List<TypeInfo> colTypes)
Registers the appropriate kind of temporary function based on a class's
type.
|
static FunctionInfo |
registerTemporaryUDF(String functionName,
Class<?> udfClass,
FunctionInfo.FunctionResource... resources)
Registers the appropriate kind of temporary function based on a class's
type.
|
static void |
setupPermissionsForBuiltinUDFs(String whiteListStr,
String blackListStr)
Setup blocked flag for all builtin UDFs as per udf whitelist and blacklist
|
static void |
unregisterPermanentFunction(String functionName) |
static void |
unregisterTemporaryUDF(String functionName) |
public static final String LEAD_FUNC_NAME
public static final String LAG_FUNC_NAME
public static final String LAST_VALUE_FUNC_NAME
public static final String UNARY_PLUS_FUNC_NAME
public static final String UNARY_MINUS_FUNC_NAME
public static final String WINDOWING_TABLE_FUNCTION
public static String getNormalizedFunctionName(String fn) throws SemanticException
SemanticException
public static FunctionInfo getFunctionInfo(String functionName) throws SemanticException
SemanticException
public static FunctionInfo getTemporaryFunctionInfo(String functionName) throws SemanticException
SemanticException
public static WindowFunctionInfo getWindowFunctionInfo(String functionName) throws SemanticException
SemanticException
public static Set<String> getFunctionNamesByLikePattern(String funcPatternStr)
funcPatternStr
- regular expression of the interested function namespublic static Set<String> getFunctionSynonyms(String funcName) throws SemanticException
funcName
- the name of the functionSemanticException
public static boolean isNumericType(PrimitiveTypeInfo typeInfo)
typeInfo
- public static boolean isExactNumericType(PrimitiveTypeInfo typeInfo)
typeInfo
- public static TypeInfo getTypeInfoForPrimitiveCategory(PrimitiveTypeInfo a, PrimitiveTypeInfo b, PrimitiveObjectInspector.PrimitiveCategory typeCategory)
a
- TypeInfo of the first typeb
- TypeInfo of the second typetypeCategory
- PrimitiveCategory of the designated common type between a and bpublic static TypeInfo getCommonClassForUnionAll(TypeInfo a, TypeInfo b)
public static TypeInfo getCommonClassForComparison(TypeInfo a, TypeInfo b)
public static PrimitiveObjectInspector.PrimitiveCategory getCommonCategory(TypeInfo a, TypeInfo b)
public static TypeInfo getCommonClass(TypeInfo a, TypeInfo b)
public static boolean implicitConvertible(PrimitiveObjectInspector.PrimitiveCategory from, PrimitiveObjectInspector.PrimitiveCategory to)
public static boolean implicitConvertible(TypeInfo from, TypeInfo to)
public static GenericUDAFEvaluator getGenericUDAFEvaluator(String name, List<ObjectInspector> argumentOIs, boolean isDistinct, boolean isAllColumns) throws SemanticException
name
- the name of the UDAFargumentOIs
- isDistinct
- isAllColumns
- SemanticException
public static GenericUDAFEvaluator getGenericWindowingEvaluator(String name, List<ObjectInspector> argumentOIs, boolean isDistinct, boolean isAllColumns) throws SemanticException
SemanticException
public static <T> Method getMethodInternal(Class<? extends T> udfClass, String methodName, boolean exact, List<TypeInfo> argumentClasses) throws UDFArgumentException
UDFArgumentException
public static GenericUDAFResolver getGenericUDAFResolver(String functionName) throws SemanticException
SemanticException
public static Object invoke(Method m, Object thisObject, Object... arguments) throws HiveException
HiveException
public static int matchCost(TypeInfo argumentPassed, TypeInfo argumentAccepted, boolean exact)
public static Method getMethodInternal(Class<?> udfClass, List<Method> mlist, boolean exact, List<TypeInfo> argumentsPassed) throws UDFArgumentException
mlist
- The list of methods to inspect.exact
- Boolean to indicate whether this is an exact match or not.argumentsPassed
- The classes for the argument.UDFArgumentException
public static GenericUDF getGenericUDFForIndex()
SemanticException
public static GenericUDF getGenericUDFForAnd()
SemanticException
public static GenericUDF cloneGenericUDF(GenericUDF genericUDF)
public static GenericUDTF cloneGenericUDTF(GenericUDTF genericUDTF)
public static boolean isDeterministic(GenericUDF genericUDF)
public static boolean isStateful(GenericUDF genericUDF)
public static boolean isOpAndOrNot(ExprNodeDesc desc)
public static boolean isOpAnd(ExprNodeDesc desc)
public static boolean isOpOr(ExprNodeDesc desc)
public static boolean isOpNot(ExprNodeDesc desc)
public static boolean isOpPositive(ExprNodeDesc desc)
public static boolean isOpCast(ExprNodeDesc desc)
public static boolean isOpCast(GenericUDF genericUDF)
public static boolean isOpPreserveInputName(ExprNodeDesc desc)
public static FunctionInfo registerTemporaryUDF(String functionName, Class<?> udfClass, FunctionInfo.FunctionResource... resources)
functionName
- name under which to register functionudfClass
- class implementing UD[A|T]Fpublic static void unregisterTemporaryUDF(String functionName) throws HiveException
HiveException
public static void registerTemporaryMacro(String macroName, ExprNodeDesc body, List<String> colNames, List<TypeInfo> colTypes)
macroName
- name under which to register the macrobody
- the expression which the macro evaluates tocolNames
- the names of the arguments to the macrocolTypes
- the types of the arguments to the macropublic static FunctionInfo registerPermanentFunction(String functionName, String className, boolean registerToSession, FunctionInfo.FunctionResource[] resources)
public static void unregisterPermanentFunction(String functionName) throws HiveException
HiveException
public static boolean impliesOrder(String functionName) throws SemanticException
functionName
- name of functionSemanticException
public static boolean pivotResult(String functionName) throws SemanticException
SemanticException
public static boolean isTableFunction(String functionName) throws SemanticException
SemanticException
public static TableFunctionResolver getTableFunctionResolver(String functionName) throws SemanticException
SemanticException
public static TableFunctionResolver getWindowingTableFunction() throws SemanticException
SemanticException
public static boolean isNoopFunction(String fnName)
public static boolean isRankingFunction(String name) throws SemanticException
name
- name of a functionSemanticException
public static boolean isBuiltInFuncExpr(ExprNodeGenericFuncDesc fnExpr)
fnExpr
- Function expression.Copyright © 2017 The Apache Software Foundation. All rights reserved.