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

Koji Noguchi commented on PIG-4897:
-----------------------------------

Rohini brought up another (more valid) case that would break with my patch.

This works.
{noformat}
knoguchi > pig -param output=/tmp/deleteme test12-1.pig
{noformat}
{code:title=test12-1.pig}
import 'test12-2.macro';
A = load 'input.txt';
mymacro(A);
{code}
{code:title=test12-2.macro}
DEFINE mymacro (A) RETURNS void {
store A into '$output';
};
{code}

But calling the above pig script with run/exec would now break even though it 
is still passing output param.
{noformat}
knoguchi > pig test12.pig
{noformat}
{code:title=test12.pig}
run -param output=/tmp/deleteme111 test12-1.pig
{code}
"Macro inline failed for macro 'mymacro'. Reason: Undefined parameter : output"

This is happening since only the param set at the root script (test12.pig) is 
propagated to the macro with my patch.

One approach I can think of to satisfy this test case as well as my [previous 
case|https://issues.apache.org/jira/browse/PIG-4897?focusedCommentId=15289823#comment-15289823]
 would be to introduce a "scope" so that param is propagated to called script 
but then dropped when the corresponding script exits.

But that would still leave 'exec setparams.pig' like usage.  Do we need to 
support this usecase? 

> Scope of param substitution for run/exec commands
> -------------------------------------------------
>
>                 Key: PIG-4897
>                 URL: https://issues.apache.org/jira/browse/PIG-4897
>             Project: Pig
>          Issue Type: Bug
>            Reporter: Koji Noguchi
>            Assignee: Koji Noguchi
>         Attachments: pig-4897-v01-notestyet.patch, pig-4897-v02.patch, 
> pig-4897-v03.patch
>
>
> After PIG-3359, pig param substitution became global in that parameter 
> declared in the pig script called from {{run}} or {{exec}} would live after 
> that script finishes.  
> This created an interesting situation.
> {code:title=test1.pig}
> exec -param output=/tmp/deleteme111 test1_1.pig
> exec -param output=/tmp/deleteme222 test1_1.pig
> {code}
> {code:title=test1_1.pig}
> %default myout '$output.out';
> A = load 'input.txt' as (a0:int);
> store A into '$myout';
> {code}
> Running {{test1.pig}} would try to run two jobs that both tries to write to 
> /tmp/deleteme111 and fail.  (Second param output=/tmp/deleteme222 is ignored.)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to