• Type: New Feature
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:


      I would like to propose a new command in Pig, FOREACH...UPDATE.

      Syntactically, it would look much like FOREACH … GENERATE.


      Input data:

      – Load the data
      three_numbers = LOAD 'input_data'
      USING PigStorage()
      AS (f1:int, f2:int, f3:int);

      – Sum up the row
      updated = FOREACH three_numbers UPDATE
      5 as f1,
      f1+f2 as new_sum

      Dump updated;

      Fields to update must be specified by alias. Any fields in the UPDATE that do not match an existing field will be appended to the end of the tuple.

      This command is particularly desirable in scripts that deal with a large number of fields (in the 20-200 range). Often, we need to only make modifications to a few fields. The FOREACH ... UPDATE statement, allows the developer to focus on the actual logical changes instead of having to list all of the fields that are also being passed through.

      My team has prototyped this with changes to FOREACH ... GENERATE. We believe this can be done with changes to the parser and the creation of a new LOUpdate. No physical plan changes should be needed because we will leverage what LOGenerate does.




            • Assignee:
     Will Lauer
              HaleyThrapp Haley Thrapp
            • Votes:
              0 Vote for this issue
              7 Start watching this issue


              • Created: