1,%default file test.txt 中不要用引號(hào),'' 和“”都不行。'file'不會(huì)被辨認(rèn)
2,等號(hào)=兩邊要注意。前必須空,后可以不空。
所以格式最好保持,等號(hào)兩邊都有空格。如A = load '$file' as (date, web, name, food);
由于編譯器肯定表名,用空格切分,無空格不行,如C= cogroup A by $0, B by $1;履行毛病,由于表C名字解析不出來,解析成了“C=”,而用C =cogroup就能夠。Pig解析中表必須后面有空格,獨(dú)立出來。
%default file test.txt
A = load '$file' as (date, web, name, food);
B = load '$file' as (date, web, name, food);
C= cogroup A by $0, B by $1;
describe C;
illustrate C;
dump C;
注意,load命令寫完后,實(shí)際不會(huì)立刻履行(例如履行describe A也只是生成1個(gè)數(shù)據(jù)結(jié)構(gòu),不會(huì)從文件中讀入數(shù)據(jù)),而是等待illustrate,和dump命令后,才會(huì)真正讀入數(shù)據(jù)到A和B中。所以1般報(bào)錯(cuò),也是在履行了dump和illustrate命令后。
5,jion,兩個(gè)關(guān)系做jion把size小的放右側(cè)。由于從左側(cè)1條1條拿,去右側(cè)比較。
6,底層的map和reduce產(chǎn)生,在于數(shù)據(jù)的操作,parallel 只能制定map。