The full name of UDF is User Defined Function. ODPS provides many built-in functions to meet user’s computing requests and user can also create user-defined functions to meet different computing needs. UDF in use is similar with ordinary Built-in Function.
In ODPS, user can expand two kinds of UDF:
|User Defined Scalar Function (also called UDF).||User Defined Scalar Function also called UDF. The relationship between input and output is one-to-one relationship. Read a row data and write an output value.|
|UDTF(User Defined Table Valued Function)||User Defined Table Valued Function, used to solve the scene that calling one function is to output multiple rows of data. It is a unique defined function which can return multiple fields, while UDF only outputs a return value.|
|UDAF(User Defined Aggregation Function)||User Defined Aggregation Function, the relationship between its input and output is one-to-many relationship. That is to aggregate multiple input records to an output value. It can be used with ‘Group By’ clause together. For details, refer to Aggregation Functions.|
- Broadly speaking, UDF stands for the set of use-defined functions, including User Defined Scalar Function, User Defined Aggregation Function and User Defined Table Valued Function. In narrow sense, it just represents user Defined Scalar Function. The document will use this term frequently and the readers can judge the specific meaning according to the context.
The data types of UDF supported by ODPS SQL include: bigint, string, double, Boolean and datetime. The correspondence of ODPS data types and Java types is shown as follows:
|ODPS SQL Type||Bigint||String||Double||Boolean||Datetime|
- NULL value in SQL is represented by NULL value in Java, so it is not allowed to use ‘Java primitive type’, which cannot represent NULL value in SQL.
Please refer to UDF Example in Quick Start Volume.