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

Johnny Zhang commented on PIG-3359:
-----------------------------------

Hi, Jonathan, few questions:

1. how to use existing script to test issue 3 (Resources (including macros) 
should not be redundantly acquired if they are already present.) ? 
nested_macro.pig and macro_with_register.pig doesn't have macros with same 
name. Do you mean by import the same file twice instead?

2. what do you mean by issue 2 (Paramater substitutions aren't done inside 
macros) will this change effect anything if macro and pig script are in the 
same file?

3. the test you added duplicatedImportTest() should follow the negative test 
case format (expecting a exception and verify the error message is the same as 
expected), please see the example like
{code:title=TestMacroExpansion.java|borderStyle=solid}
// macro doesn't contain return alias
    @Test
    public void negativeTest6() throws Throwable {
        String macro = "define group_and_count (A,C) returns B {\n" +
            "    B = JOIN $A BY $B, $C BY user;\n" +
            "};\n";
        
        String script = 
            "alpha = load 'users' as (user, age, zip);\n" +
            "beta = load 'links' as (user, link, view);\n" +
            "gamma = group_and_count (alpha,beta);\n" +
            "store gamma into 'byuser';\n";
        
        String expectedErr = "Reason: Macro 'group_and_count' missing return 
alias: B";
        
        validateFailure(macro + script, expectedErr);
    }
{code}
              
                
> Register Statements and Param Substitution in Macros
> ----------------------------------------------------
>
>                 Key: PIG-3359
>                 URL: https://issues.apache.org/jira/browse/PIG-3359
>             Project: Pig
>          Issue Type: Bug
>          Components: parser
>            Reporter: Jonathan Packer
>            Assignee: Jonathan Packer
>         Attachments: PIG-3359_test.tar.gz, PIG-3359-v1.diff, PIG-3359-v2.diff
>
>
> There are some gaps in the functionality of macros that I've made a patch to 
> address. The goal is to provide everything you'd need to make reusable 
> algorithms libraries.
> 1. You can't register udfs inside a macro
> 2. Paramater substitutions aren't done inside macros
> 3. Resources (including macros) should not be redundantly acquired if they 
> are already present.
> Rohini's patch https://issues.apache.org/jira/browse/PIG-3204 should address 
> problem 3 where Pig reparses everything every time it reads a line, but there 
> still would be a problem if two separate files import the same macro / udf 
> file.
> To get this working, I moved methods for registering jars/udfs and param 
> substitution from PigServer to PigContext so they can be accessed in 
> QueryParserDriver which processes macros (QPD was already passed a PigContext 
> reference). Is that ok?

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