pig拉丁语排序

yqkkidmi  于 2021-06-25  发布在  Pig
关注(0)|答案(1)|浏览(461)

我正在测试apache pig docs中的以下示例:
http://pig.apache.org/docs/r0.14.0/basic.html#order-由
但排序功能似乎不起作用。你知道吗?

$ pig -version
Apache Pig version 0.14.0 (r1640057) 
compiled Nov 16 2014, 18:02:05

grunt> a= load 'data' as (c1:int, c2:int, c3:int);
grunt> describe a;
a: {c1: int,c2: int,c3: int}
grunt> dump a;
(1,2,3)
(4,2,1)
(8,3,4)
(4,3,3)
(7,2,5)
(8,4,3)
grunt> result = order a by c1 desc;
grunt> dump result; 
(8,4,3)
(8,3,4)
(4,3,3)
(4,2,1)
(1,2,3)
(7,2,5)
grunt> result = order a by c2 desc;
grunt> dump result;
(8,4,3)
(7,2,5)
(4,2,1)
(1,2,3)
(4,3,3)
(8,3,4)
grunt> result = order a by c3 desc;
grunt> dump result;                
(7,2,5)
(4,3,3)
(8,4,3)
(1,2,3)
(4,2,1)
(8,3,4)
8dtrkrch

8dtrkrch1#

您正在使用默认分隔符加载数据( tab )但实际输入的数据并没有正确地用tab分隔。您能确保您的输入数据字段是由文件中的制表符分隔的吗 'data' .
在下面的示例中,每个输入字段由制表符及其工作区分隔。

data:
1<TAB>2<TAB>3
4<TAB>2<TAB>1
8<TAB>3<TAB>4
4<TAB>3<TAB>3
7<TAB>2<TAB>5
8<TAB>4<TAB>3

grunt> a= load 'data' as (c1:int, c2:int, c3:int);
(1,2,3)
(4,2,1)
(8,3,4)
(4,3,3)
(7,2,5)
(8,4,3)
grunt> result = order a by c1 desc;
grunt> dump result;
(8,3,4)
(8,4,3)
(7,2,5)
(4,2,1)
(4,3,3)
(1,2,3)
grunt> result = order a by c2 desc;
grunt> dump result;
(8,4,3)
(8,3,4)
(4,3,3)
(1,2,3)
(4,2,1)
(7,2,5)
grunt> result = order a by c3 desc;
grunt> dump result; 
(7,2,5)
(8,3,4)
(1,2,3)
(4,3,3)
(8,4,3)
(4,2,1)

相关问题