You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by "Richard Ding (JIRA)" <ji...@apache.org> on 2011/03/29 23:29:06 UTC

[jira] [Commented] (PIG-1873) Pig try to interpret UDF as Macro

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

Richard Ding commented on PIG-1873:
-----------------------------------

This is addressed by PIG-1931 where Macro inline is allowed only as top-level statements. One cannot invoke/inline a macro in a nested block (it'll cause a parser error). 

By disallowing macro invocation in nested blocks we avoid the problem raised by this jira, i.e., parser ambiguity between macro invocation and assignment with UDF.





> Pig try to interpret UDF as Macro
> ---------------------------------
>
>                 Key: PIG-1873
>                 URL: https://issues.apache.org/jira/browse/PIG-1873
>             Project: Pig
>          Issue Type: Bug
>          Components: impl
>    Affects Versions: 0.9.0
>            Reporter: Daniel Dai
>            Assignee: Richard Ding
>             Fix For: 0.9.0
>
>         Attachments: PIG-1873.patch
>
>
> The following script fail:
> {code}
> A = load '1.txt';
> B = group A by $0;
> C = foreach B {
>     C1 = filter A by $0 > -1;
>     C2 = distinct C1;
>     C3 = distinct A;
>     C4 = org.apache.pig.test.utils.Identity(*);
>     C5 = COUNT(C2);
>     C6 = SUM(C2.$1);
>     C7 = org.apache.pig.test.TestEvalPipeline\$TitleNGrams(C3);
>     C8 = MAX(C3.$1);
>     generate (int)group, C4, C5, C6, C7, C8, C2;
> };
> dump C;
> {code}
> Stack:
> ERROR 2999: Unexpected internal error. Pig macro 'COUNT' must be defined before being invoked
> java.lang.RuntimeException: Pig macro 'COUNT' must be defined before being invoked
>         at org.apache.pig.parser.MacroExpansion.mINLINE(MacroExpansion.java:509)
>         at org.apache.pig.parser.MacroExpansion.mTokens(MacroExpansion.java:1240)
>         at org.apache.pig.parser.MacroExpansion.nextToken(MacroExpansion.java:68)
>         at org.apache.pig.parser.ParserUtil.expandMacros(ParserUtil.java:53)
>         at org.apache.pig.parser.ParserUtil.getExpandedMacroAsBufferedReader(ParserUtil.java:89)
>         at org.apache.pig.Main.run(Main.java:505)
>         at org.apache.pig.Main.main(Main.java:108)
> Seems Pig try to interpret UDF COUNT as a Macro.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira