【问题标题】:PIG Group into bag by distinct valuePIG Group 按不同价值入袋
【发布时间】:2017-11-25 12:23:03
【问题描述】:
recipe,ingredient,inventor
Tacos,Beef,Alex
Tacos,Lettuce,Alex
Tacos,Cheese,Alex
TomatoSoup,Tomatoes,Steve
TomatoSoup,Milk,Steve

我想按配方对记录进行分组,然后将配料和发明者放在一起

(Tacos,{Beef,Lettuce,Cheese},Alex)
(TomatoSoup,{Tomatoes,Milk},Steve)

【问题讨论】:

    标签: apache-pig


    【解决方案1】:

    按配方和发明者分组,然后根据您的要求对列进行排序。

    A = LOAD 'data.txt' USING PigStorage(',') AS (recipe:chararray,ingredient:chararray,inventor:chararray);
    B = GROUP A BY (recipe,inventory);
    C = FOREACH B GENERATE FLATTEN(group) as (recipe,inventor),A.ingredient;
    D = FOREACH C GENERATE recipe,ingredient,inventory;
    DUMP D;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多