Pig
  1. Pig
  2. PIG-3239

Unable to return multiple values from a macro using SPLIT

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 0.10.0
    • Fix Version/s: 0.12.0
    • Component/s: None
    • Labels:
      None
    • Environment:

      Apache Pig version 0.10.0-cdh4.2.0 (rexported)
      compiled Feb 15 2013, 12:19:17

      Linux 3.2.0-38-generic #61-Ubuntu SMP Tue Feb 19 12:18:21 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

      Description

      Hi, I'm unable to return multiple values from a macro when values come from a SPLIT. Here is an small example:

      DEFINE my_macro(seq) RETURNS valid, invalid {
          added = FOREACH $seq GENERATE $0 * 2, $1;
          SPLIT added INTO $valid IF $1 == true, $invalid OTHERWISE;
      }
      
      data = LOAD 'case.csv' USING PigStorage(',') AS (value: int, valid: boolean);
      P, Q = my_macro(data);
      DUMP P;
      DUMP Q;
      

      Pig is unable to recognize the OTHERWISE side. Error is: ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1200: <at case.pig, line 3> Invalid macro definition: . Reason: Macro 'my_macro' missing return alias: invalid

      Simple workaround is to force $invalid to be returned as FOREACH result:

      SPLIT added INTO $valid IF $1 == true, tmp_invalid OTHERWISE;
      $invalid = FOREACH tmp_invalid GENERATE *;
      

      Samples and logs attached to the issue.

      1. PIG-3239.patch.txt
        0.7 kB
        Johnny Zhang
      2. PIG-3239.patch.txt
        2 kB
        Johnny Zhang

        Activity

          People

          • Assignee:
            Johnny Zhang
            Reporter:
            Luis Belloch
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development