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

Johnny Zhang commented on PIG-2378:
-----------------------------------

I think it is not a bug, using
{noformat}
B = MY_MACRO(A, 'header.time');
{noformat}
should just make it work.

I try it in pig 0.11 release by below test:
1. macro.pig
{noformat}
a = load '/var/lib/jenkins/macro' as (f1:int, f2:int, f3:int);
dump a;
b = foreach a generate f1, (f2, f3) as f5;
dump b;
describe b;
define macro1 (c, d) returns e {
$e = group $c by $d;
}
e = macro1 (b, 'f5.f2');
dump e;
{noformat}

2. data macro
{noformat}
1       2       3
4       5       6
7       8       9
{noformat}

3. run the test by 'pig -x local macro.pig' gets result
{noformat}
(2,{(1,(2,3))})
(5,{(4,(5,6))})
(8,{(7,(8,9))})
{noformat}

[~jadler], could you please verify whether it works for you? Thanks.
                
> macros don't accept references to items within tuples as arguments
> ------------------------------------------------------------------
>
>                 Key: PIG-2378
>                 URL: https://issues.apache.org/jira/browse/PIG-2378
>             Project: Pig
>          Issue Type: Improvement
>    Affects Versions: 0.9.1
>            Reporter: Joseph Adler
>
> I'd like to be able to pass a reference to an item within a parameter to a 
> Pig Macro.
> For example, suppose that I had a relation A with the schema A:{id:long, 
> header:(time:long, type:chararray)}. I'd like to call a macro by typing:
>    B = MY_MACRO(A, header.time);
> but this does not currently work. Obviously, I could define a new relation as 
> a workaround, for example I could use some pig code like 
>   AA = FOREACH a GENERATE *, header.time as time;
>   B = MY_MACRO(AA, time);
> But that's ugly and clunky

--
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