Hi All,
I wrote hive UDF to convert
07/Dec/2014:23:59:04 to 07-Dec-2014 23:59:04
I attached UDF. PFA ...
I added jar to hive and created temporary function
*stringTotimestampQuery: select stringTotimestamp(date) from rm_get limit
1;*
*Result: *
[image: Inline image 1]
*Query: select to_date(stringTotimestamp(date)) from rm_get limit 1;*
*Result: Null*
What may be the issue?
--
With Thanks & Regards
Nagarjuna Vissarapu
9052179339
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.Text;
public class DateSet extends UDF {
public String evaluate(Text input) {
if (input == null)
return null;
String rawTimeStamp = input.toString();
rawTimeStamp = rawTimeStamp.replaceAll("/", "-");
System.out.println(rawTimeStamp);
int firstocc = rawTimeStamp.indexOf(":");
System.out.println(firstocc);
String timeSep = rawTimeStamp.substring(firstocc+1, rawTimeStamp.length());
timeSep = timeSep.trim();
rawTimeStamp = rawTimeStamp.substring(0, firstocc);
String convertedFormat = rawTimeStamp+" "+timeSep;
return convertedFormat;
}
}