猪被压扁并分组

时间:2015-04-06 18:32:04

标签: hadoop apache-pig

我有两个文件,我想将这些文件联合起来生成一个文件作为输出。

file1 = "Hello world"
file2 = "I am x";
c = union file1,file2;
group = group c all;
group = (all,{(Hello world),(I am x)});

我希望输出为(Hello world我是x);

如何实现呢?我试过了:

res = foreach group generate flatten(all);

但它不起作用..

1 个答案:

答案 0 :(得分:0)

试试这个..

x = load 'pigin1.txt' as (str1:chararray);

y = load 'pigin.txt' as (str2:chararray);

z = rank x;

z1 = rank y;

z2 = join z by rank_x,z1 by rank_y;

z3 = foreach z2 generate  CONCAT(z::str1,z1::str2);

dump z3;