1
這兩級pig
處理工程:如何將兩條豬語句合併爲一個?
my_out = foreach (group my_in by id) {
grouped = BagGroup(my_in.(keyword,weight),my_in.keyword);
generate
group as id,
CountEach(my_in.domain) as domains,
grouped as grouped;
};
my_out1 = foreach my_out {
keywords = foreach grouped generate group as keyword, SUM($1.weight) as weight;
generate id, domains, keywords;
};
然而,當我將它們合併:
my_out = foreach (foreach (group my_in by id) {
grouped = BagGroup(my_in.(keyword,weight),my_in.keyword);
generate
group as id,
CountEach(my_in.domain) as domains,
grouped as grouped;
}) {
keywords = foreach grouped generate group as keyword, SUM($1.weight) as weight;
generate id, domains, keywords;
};
我得到一個錯誤:
ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1000: Error during parsing. Encountered " <IDENTIFIER> "generate "" at line 1, column 5.
我的問題是:
- 如何避免此錯誤?
- 它甚至有道理我正在嘗試做什麼? 即使我設法做到這一點,這將節省我一個MR通行證?
我得到'ERROR 1000:解析時出錯。詞彙錯誤在第25行第0列。遇到:之後:「」你的代碼 –
sds
Darn。那麼你可能會倒黴。但請放心,它不會添加任何map-reduce作業來將語句拆分。 –