1

私が3つのファイルを持っているとしましょうdata1data2そしてassocs

$ cat data1
key1,foo
key2,bar
$ cat data2
key3,braz
key4,froz
$ cat assoc 
key1,key3
key2,key4

これらのファイルを

$ pig -b -p debug=WARN -x local
Warning: $HADOOP_HOME is deprecated.

Apache Pig version 0.10.0 (r1328203) compiled Apr 19 2012, 22:54:12
Logging error messages to: /home/vince/tmp/pig_1355407390166.log
Connecting to hadoop file system at: file:///
grunt> data1 = load 'data1' using PigStorage(',') as (key: chararray, val: chararray);  
grunt> data2 = load 'data2' using PigStorage(',') as (key: chararray, val: chararray);  
grunt> assoc = load 'assoc' using PigStorage(',') as (key1: chararray, key2: chararray);

私が欲しいのは、次のような関係です。

(foo, braz)
(bar, froz)

あれは

data1_val, data1_key <-> assoc_key1, assoc_key2 <-> data2_key, data2_val
4

1 に答える 1

3
A = join data1 by key, assoc by key1;
B = join A by assoc::key2, data2 by key;
RES = foreach B generate A::data1::val, data2::val;
于 2012-12-13T16:24:59.047 に答える