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

Aniket Mokashi commented on PIG-928:
------------------------------------

Proposed syntax for the Script UDF registration-

1. Registration of entire script-
test.py has helloworld, complex etc.
{code}
register 'test.py' lang python;
b = foreach a generate helloworld(a.$0), complex(a.$1);
{code}
This registers all functions in test.py as pig UDFs.

Issues- (as per current implementation)
1. flat namespace- this consumes the UDF namespace. Do we need to have 
test.py.helloworld?
2. no way to find signature- We do not verify signature of helloworld in front 
end, user has no feedback about UDF signatures.
3. Dependencies- no ship clause.

Optional command-
{code}
describe 'test.py';
helloworld{x:chararray};
complex{i:int};
{code}

Changes needed- ScriptEngine needs to have a function that for a given script 
and funcspec dumps the function signature if funcspec if the function is 
present in the script (given path).
abstract void dumpFunction(String path, FuncSpec funcSpec, PigContext 
pigContext);

2. Registration of single UDF from a script-
test.py has helloworld which has dependencies in '1.py' and '2.py'.
{code}
define helloworld lang python source 'test.py' ship ('1.py', '2.py');
OR
define hello lang python source 'test.py'#helloworld ship ('1.py', '2.py');
b = foreach a generate helloworld(a.$0);
{code}
This registers helloworld (/hello) as pig UDF.

Also,
ScriptEngine -> getStandardScriptJarPath() returns path for standard location 
of jython.jar (user can override this with register jython5.jar etc). We ship 
this jar if user does not explicitly specify one.
ScriptEngine.getInstance maps keyword "python" to appropriate ScriptEngine 
class.

Attached is initial implementation for register script clause and parse patch 
has parsing related initial changes for define clause.
[RegisterPythonUDF2.patch, RegisterScriptUDFDefineParse.patch ]

> UDFs in scripting languages
> ---------------------------
>
>                 Key: PIG-928
>                 URL: https://issues.apache.org/jira/browse/PIG-928
>             Project: Pig
>          Issue Type: New Feature
>            Reporter: Alan Gates
>            Assignee: Aniket Mokashi
>             Fix For: 0.8.0
>
>         Attachments: calltrace.png, package.zip, pig-greek.tgz, 
> pig.scripting.patch.arnab, pyg.tgz, RegisterPythonUDF2.patch, scripting.tgz, 
> scripting.tgz, test.zip
>
>
> It should be possible to write UDFs in scripting languages such as python, 
> ruby, etc.  This frees users from needing to compile Java, generate a jar, 
> etc.  It also opens Pig to programmers who prefer scripting languages over 
> Java.

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