Reputation: 1437
I have a data like this
Start_time End_time 12:10:30 13:10:00
I want to store this in pig and calculate elapsed time. How can i do this in pig ? I simply wrote Start_time-End_time but the result is blank
Upvotes: 0
Views: 85
Reputation: 1406
The query will be similar to this:
time = LOAD '/user/name/input_folder/file_name' USING PigStorage() AS (sd:chararray, ed:chararray, t1:chararray, t2:chararray);
A = FOREACH time GENERATE $0, $1, GetHour(ToDate(t1,'HH:mm:ss')) as hour1, GetHour(ToDate(t2,'HH:mm:ss')) as hour2;
B = FOREACH A GENERATE ($3 - $2) as time_elapsed;
dump B;
Upvotes: 2