将具有非标准分隔符的文件加载到pig中

时间:2012-10-05 01:01:09

标签: apache-pig

我有一个如下所示的文件,其中的字段由'?'分隔:

(01-01-2011-04:43:50?2521795691802591407?94.20.58.165?

当我使用

mac = load 'Activity_1295336_01-01-2011.log.gz'using PigStorage('?');

我仍然无法访问内部字段,例如mac$1

1 个答案:

答案 0 :(得分:0)

在我这边按预期工作......

$> pig --version
Apache Pig version 0.9.2-cdh4.0.0 (rexported) 
compiled Jun 04 2012, 17:42:27

$> cat temp1
01-01-2011-04:43:50?2521795691802591407?94.20.58.165?

grunt> a = load '/temp1' using PigStorage('?') as (datetime, id, ip); 
grunt> dump a;
grunt> >> (01-01-2011-04:43:50,2521795691802591407,94.20.58.165,)
grunt> b = foreach a { funky = CONCAT(ip, '_-* FUNKY'); generate datetime, id, funky;}
grunt> dump b;
grunt> >> (01-01-2011-04:43:50,2521795691802591407,94.20.58.165_-* FUNKY)