2

我在 pig generate 函数中遇到了一个奇怪的问题,如果我不使用第一个字段,生成的数据似乎是错误的。这是预期的行为吗?

 a = load '/input/temp2.txt' using PigStorage(' ','-tagFile') as      (fname:chararray,line:chararray) ;
grunt> b = foreach a generate $1;
grunt> dump b;
      (temp2.txt)
      (temp2.txt)
grunt> c = foreach a generate $0,$1;
grunt> dump c;
       (temp2.txt,field1,field2)
       (temp2.txt,field1,field22)

$cat temp2.txt
field1,field2
field1,field22


pig -version
Apache Pig version 0.15.0 (r1682971)
compiled Jun 01 2015, 11:44:35

在示例中,我期望 dump b 返回数据文件值而不是文件名

4

1 回答 1

0

在您的示例中,您使用PigStorage(' ','-tagFile'), 所以每一行都被空格分隔。

然后:

$0 -> 字段 1,字段 2

$1 -> 没有,

只需使用PigStorage(',','-tagFile').

于 2015-10-31T13:24:39.977 回答