猪ToDate功能不正常

时间:2017-03-01 05:14:14

标签: apache-pig

我正在尝试使用日期功能进行施法。

 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 ;

我收到以下错误

Scalar在输出中有多行。第1名:     (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)

输入

 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 个答案:

答案 0 :(得分:1)

  

没有尝试实际操作:但您的输入日期格式为01/29/2015   01:40:35即MM / dd / YYYY HH:mm:ss。而你已将其指定为   ' yyyy / MM / dd HH:mm:ss'

尝试类似:

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