Pig
  1. Pig
  2. PIG-2530

Reusing alias name in nested foreach causes incorrect results

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 0.9.2, 0.10.0
    • Fix Version/s: 0.10.0, 0.9.3, 0.11
    • Component/s: None
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      The below script results in incorrect output for Pig 0.10 but runs fine with Pig 0.8,

      input.txt
      1	4
      1	3
      2	3
      2	4
      
      a = load 'input.txt' as (v1:int, v2:int);
      b = group a by v1;
      c = foreach b { x = a; x = order x by v2 asc; generate flatten(x); }
      store c into 'c1';
      

      Output from Pig 0.10
      --------------------
      1 4
      1 3
      2 3
      2 4

      Looking at the explain, it seems like the sorting is entirely missed out.
      The script produces correct results if I change the alias name ie;

      c = foreach b

      { x = a; x1 = order x by v2 asc; generate flatten(x1); }
      1. PIG-2530-0.patch
        4 kB
        Daniel Dai
      2. PIG-2530-1.patch
        6 kB
        Thomas Weise
      3. PIG-2530-2.patch
        2 kB
        Daniel Dai

        Activity

        Vivek Padmanabhan created issue -
        Daniel Dai made changes -
        Field Original Value New Value
        Attachment PIG-2530-0.patch [ 12514474 ]
        Thomas Weise made changes -
        Attachment PIG-2530-1.patch [ 12514739 ]
        Daniel Dai made changes -
        Attachment PIG-2530-2.patch [ 12514766 ]
        Daniel Dai made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Hadoop Flags Reviewed [ 10343 ]
        Assignee Daniel Dai [ daijy ]
        Fix Version/s 0.10 [ 12316246 ]
        Fix Version/s 0.11 [ 12318878 ]
        Resolution Fixed [ 1 ]
        Thomas Weise made changes -
        Fix Version/s 0.9.3 [ 12319456 ]
        Daniel Dai made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Daniel Dai
            Reporter:
            Vivek Padmanabhan
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development