Uploaded image for project: 'Pig'
  1. Pig
  2. PIG-1665

Add cross as a nested_op

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 0.7.0
    • None
    • grunt
    • None

    Description

      It would be good to be able to cross inside a foreach:

      A = load 'data' as (ind:int, ind2:int, ind3:int, value:int);
      B = group A by ind;
      C = foreach B {
         c = cross A.(ind2, value), A.(ind3, value);
         generate group as ind, FLATTEN(c) as (ind2, value1, ind3, value2);
      }
      

      This reassures me that the cross is happening only within the group of ind1 and not generating a full (ind1, ind2, ind3) cross, and then limiting to just one ind1.

      In the words of the manual Pig Latin Reference Manual 2, ver0.7 this ticket asks for "cross" to be added as a "nested_op". Consider also the following example:

      A = load 'data' as (ind:int, ind2:int, ind3:int, ind4:int, value:int);
      B = group A by ind;
      C = foreach B {
         c1 = cross A.(ind2, value), A.(ind3, value);
         c2 = cross A.(ind2, value), A.(ind4, value);
         generate group as ind, FLATTEN(c1) as (ind2, value1, ind3, value2), FLATTEN(c2) as (ind4, value1, ind5, value2);
      }
      

      which you would not be able to accomplish without a cross nested_op.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              hcbusy hc busy
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: