Pig 将行转换为列
Pig convert rows to columns
下面是变量data
的dump
。
(104)
(105)
(106)
(107)
(108)
(111)
(112)
(113)
(114)
(115)
(119)
(120)
如何将其转换为 tuples
的 bag
,如下所示(最好不使用 UDF
):
{(104),(105),(106),(107),(108),(111),(112),(113),(114),(115),(119),(120)}
使用GROUP ALL
http://pig.apache.org/docs/r0.16.0/basic.html#group
Use ALL if you want all tuples to go to a single group; for example, when doing aggregates across entire relations.
A = LOAD '/tmp/data.txt' AS (n:int);
B = GROUP A ALL;
C = FOREACH B GENERATE ;
下面是变量data
的dump
。
(104)
(105)
(106)
(107)
(108)
(111)
(112)
(113)
(114)
(115)
(119)
(120)
如何将其转换为 tuples
的 bag
,如下所示(最好不使用 UDF
):
{(104),(105),(106),(107),(108),(111),(112),(113),(114),(115),(119),(120)}
使用GROUP ALL
http://pig.apache.org/docs/r0.16.0/basic.html#group
Use ALL if you want all tuples to go to a single group; for example, when doing aggregates across entire relations.
A = LOAD '/tmp/data.txt' AS (n:int);
B = GROUP A ALL;
C = FOREACH B GENERATE ;