Hi,

I have the following requirement from a Hive table below.

CustNumActivityDatesRates
10010-Aug-13,12-Aug-13,20-Aug-1310,15,20

The data above says that

From 10 Aug to 11 Aug the rate is 10.
From 12 Aug to 19 Aug the rate is 15.

From 20-Aug to till date the rate is 20.

Note : The order is maintained in 'ActivityDates' and 'Rates'.

From the above table , I need to find the rate on say a given date 15-Aug-13. 
In the above case , the rate for 15-Aug-13 is 15.

How should I get this result in Hive.

I was reading about a Generic UDF and was thinking to write one like this.
The Generic UDF takes two inputs (input date , array of input dates ) . the 
output should be (an int )to return the element number in the array. 

In the above case 
Generic UDF(15-Aug-13,10-Aug-13,12-Aug-13,20-Aug-13) should return the 2nd 
element in array - 2.



Please advise if there is an alternative solution or if the above solution 
works. I have never written a UDF or Generic UDF and would need some help from 
the forum members. Please advise.


Regards,
Raj

Reply via email to