In Hive, there are a lot of user defined functions(UDF) same as SQL and Oracle. UDF can be implemented in our code when we are unable to implement the logic with HIVE. UDF can be invoke using hive query.
Types of UDF Function:-
1) Simple UDF
2) UDAF (User-Defined Aggregate Function)
3) UDTF (User Defined Tabular Function)
1) Simple UDF: – Single row function. UDF perform the operation only on a single row and return output as a single row.
2) UDAF: – It works on the multiple rows and gives output as a single row. e.g. MIN() Function. Consider an example having 20 rows of data in a table account. We want to find the account holder having the minimum balance. It will process on 20 rows and result in output as a single row.
3) UDAF: It works on the single row and returns output as multiple rows.
How to write a UDF Function:-
We need to write a simple java code where we will implement our logic. We can use more than one logic in single code. Consider an example, we have a table having city name, Date and temperature in fernehite. we want to convert fernehite into celsius and also the name of the city to upper case. We can implement both in the same set of code.
