错误1070:无法使用导入解析todate

j2datikz  于 2021-06-24  发布在  Pig
关注(0)|答案(1)|浏览(261)

详情如下:
日期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.]

fykwrbwg

fykwrbwg1#

输入日期格式为 MM/dd/yyyy .

C = FOREACH B GENERATE ToDate(tripdate,'MM/dd/yyyy') as mytripdate;

如果希望日期采用“yyyy-mm-dd”格式,请使用 ToString() ```
C = FOREACH B GENERATE ToString(ToDate(tripdate,'MM/dd/yyyy'),'yyyy-MM-dd') as mytripdate;

相关问题