[ 
https://issues.apache.org/jira/browse/PIG-3239?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13602540#comment-13602540
 ] 

Cheolsoo Park commented on PIG-3239:
------------------------------------

Chatted with Johnny, and it looks like TestMacroExpansion isn't a good place to 
put a new test case for this. It might be better to add one to TestSplit.
                
> Unable to return multiple values from a macro using SPLIT
> ---------------------------------------------------------
>
>                 Key: PIG-3239
>                 URL: https://issues.apache.org/jira/browse/PIG-3239
>             Project: Pig
>          Issue Type: Bug
>    Affects Versions: 0.10.0
>         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
>            Reporter: Luis Belloch
>            Assignee: Johnny Zhang
>            Priority: Minor
>         Attachments: PIG-3239.patch.txt
>
>
> Hi, I'm unable to return multiple values from a macro when values come from a 
> SPLIT. Here is an small example:
> {code}
> 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;
> {code}
> 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:
> {code}
> SPLIT added INTO $valid IF $1 == true, tmp_invalid OTHERWISE;
> $invalid = FOREACH tmp_invalid GENERATE *;
> {code}
> Samples and logs attached to the issue.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to