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

Woody Anderson commented on PIG-1824:
-------------------------------------

The following may not be immediately self evident to all developers:

import statements that execute from within runtime function calls will not work 
(unless the dependency has already been satisfied statically), eg:
{code}
def resplit(content, regex, index):
 import re
 return re.compile(regex).split(content)[index]
{code}

will not work b/c the import is not attempted until after the job has been 
defined, built, and deployed.
This import practice is frowned upon and is used very rarely. If you happen to 
be doing it (i'll assume you have a good reason), then you probably know how to 
fix it. If you're using someone else's code that is written like this, you can 
satisfy the dependency by explicitly importing the module up front, this will 
cause it to be added to the jar, and subsequent uses will succeed.


> Support import modules in Jython UDF
> ------------------------------------
>
>                 Key: PIG-1824
>                 URL: https://issues.apache.org/jira/browse/PIG-1824
>             Project: Pig
>          Issue Type: Improvement
>    Affects Versions: 0.8.0, 0.9.0
>            Reporter: Richard Ding
>            Assignee: Woody Anderson
>             Fix For: 0.8.0, 0.9.0, 0.10
>
>         Attachments: 1824.patch
>
>
> Currently, Jython UDF script doesn't support Jython import statement as in 
> the following example:
> {code}
> #!/usr/bin/python
> import re
> @outputSchema("word:chararray")
> def resplit(content, regex, index):
>         return re.compile(regex).split(content)[index]
> {code}
> Can Pig automatically locate the Jython module file and ship it to the 
> backend? Or should we add a ship clause to let user explicitly specify the 
> module to ship? 

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

Reply via email to