详情如下:
日期2.txt
B02617,2/27/2015,1551,14677
B02598,2/27/2015,1114,10755
B02512,2/27/2015,272,2056
B02764,2/27/2015,4253,38780
Pig脚本:
A = Load '/files/date2.txt' using PigStorage(',') as (base:chararray, tripdate:chararray, cars:int, tripkms:int);
B = FOREACH A GENERATE tripdate;
C = FOREACH B GENERATE ToDate(tripdate,'yyyy-MM-dd') as mytripdate;
这就是我得到的错误:
main]error org.apache.pig.tools.grunt.grunt-错误1070:无法使用导入解析todate:[,org.apache.pig.builtin.,org.apache.pig.impl.builtin.]
1条答案
按热度按时间fykwrbwg1#
输入日期格式为
MM/dd/yyyy
.如果希望日期采用“yyyy-mm-dd”格式,请使用
ToString()
```C = FOREACH B GENERATE ToString(ToDate(tripdate,'MM/dd/yyyy'),'yyyy-MM-dd') as mytripdate;