0
votes

i am trying cast field with date function.

 raw_data = LOAD '/user/cloudera/Chicago_Traffic_Tracker_-  _Historical_Congestion_Estimates_by_Region.csv' USING PigStorage(',') AS ( TIME   :chararray,REGION_ID:int,BUS_COUNT:int,NUMBER_OF_READS:int,SPEED:double); 

 raw_clean = FOREACH raw_data GENERATE ToDate(raw_data.TIME,'yyyy/MM/dd HH:mm:ss')as date_time:DateTime ;

I get the below error

Scalar has more than one row in the output. 1st : (01/29/2015 01:40:35 PM,22,33,429,25.23), 2nd :(01/05/2015 01:10:46 PM,18,58,1058,21.14)

Input

 01/29/2015 01:40:35 PM,22,33,429,25.23,a61e11c83f811b63e1dc64362f799dcac322fca8
 01/05/2015 01:10:46 PM,18,58,1058,21.14,39c63427d0e1401a06f967fd43c30e291140c26e
1

1 Answers

1
votes

Didn't try practicals: But Your Input date is in format 01/29/2015 01:40:35 i.e MM/dd/YYYY HH:mm:ss . Whereas you have specified it as 'yyyy/MM/dd HH:mm:ss'

Try something like :

raw_clean = FOREACH raw_data GENERATE ToDate(raw_data.TIME,'MM/dd/YYYY HH:mm:ss');