Ashutosh Chauhan commented on PIG-598:

One issue I faced while working on PIG-928 was when trying to name variables in 
ruby bound to java variables. Ruby variable  names (in BSF) needs to be 
prepended with $ as shown below. 
define myudf org.apache.pig.scriptedUDFs.GenericEvalFunc('wordtokens','return 
Now this $ appearing in the script should not be substituted. But parser tries 
to substitute it and fails (with error undefined parameter) since param is not 
specified while invoking Pig. My hack was to 'escape' this $ and then provide 
param-substiution while invoking the script as -p input=input 
define myudf org.apache.pig.scriptedUDFs.GenericEvalFunc('wordtokens','return 
Note extra $. Obviously, if we are thinking of adding pig-928 and accept udfs 
written in ruby, this will come up as an issue. One possibility is Pig should 
not try to do substitution if param is not specified on cmd line. I think way 
it currently is parser scans the script for $ and then tries to do substiution. 
If substitution was not defined it error outs. I think if it is not specified 
on cmd line, then parser should ignore it and continue instead of failing.   

> Parameter substitution ($PARAMETER) should not be performed in comments
> -----------------------------------------------------------------------
>                 Key: PIG-598
>                 URL: https://issues.apache.org/jira/browse/PIG-598
>             Project: Pig
>          Issue Type: Bug
>          Components: impl
>    Affects Versions: 0.2.0
>            Reporter: David Ciemiewicz
>            Assignee: Thejas M Nair
>         Attachments: PIG-598.patch
> Compiling the following code example will generate an error that 
> $NOT_A_PARAMETER is an Undefined Parameter.
> This is problematic as sometimes you want to comment out parts of your code, 
> including parameters so that you don't have to define them.
> This I think it would be really good if parameter substitution was not 
> performed in comments.
> {code}
> {code}
> {code}
> -bash-3.00$ pig -exectype local -latest comment.pig
> USING: /grid/0/gs/pig/current
> java.lang.RuntimeException: Undefined parameter : NOT_A_PARAMETER
>         at 
> org.apache.pig.tools.parameters.PreprocessorContext.substitute(PreprocessorContext.java:221)
>         at 
> org.apache.pig.tools.parameters.ParameterSubstitutionPreprocessor.parsePigFile(ParameterSubstitutionPreprocessor.java:106)
>         at 
> org.apache.pig.tools.parameters.ParameterSubstitutionPreprocessor.genSubstitutedFile(ParameterSubstitutionPreprocessor.java:86)
>         at org.apache.pig.Main.runParamPreprocessor(Main.java:394)
>         at org.apache.pig.Main.main(Main.java:296)
> {code}

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

Reply via email to