I'm trying to use Date functions built into pig.
The input file contains date in yyyy-mm-dd hh:mi:ss
format.
I'm trying to use the following code:
row = foreach log generate FLATTEN(REGEX_EXTRACT_ALL (pattern) AS (date_time : datetime, other columns);
final_data = foreach row {
yyyy = (chararray)GetYear(date_time);
mm = (chararray)GetMonth(date_time);
dd = (chararray)GetDay(date_time);
hh = (chararray)GetHour(date_time);
mi = (chararray)GetMinute(date_time);
ss = (chararray)GetSecond(date_time);
generate CONCAT(CONCAT(CONCAT(yyyy, '-'), CONCAT(mm, '-')),dd) as myDate;
}
but I get an error:
ERROR 1066: Unable to open iterator for alias final_data. Backend error : java.lang.String cannot be cast to org.joda.time.DateTime
I'm trying to use workaround from: Formatting Date in Generate Statement
What format is expected?