You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Norbert Burger <no...@gmail.com> on 2011/07/26 16:21:29 UTC
return dict from Python UDF?
Hi all - I'm having some difficulty returning a dict/map from a Python UDF.
The following code returns "java.lang.String cannot be cast to
org.python.core.PyObject". What am I missing?
Thanks,
Norbert
Here's my test Pig script:
REGISTER 'pigfuncs.py' USING jython AS pigfuncs;
cvps = LOAD 'test.txt' USING PigStorage();
A = FOREACH cvps GENERATE pigfuncs.createmap() as dict;
B = FOREACH A GENERATE dict#'asdf';
dump B;
And the Python UDF:
@outputSchema("m:map[]")
def createmap():
d = {}
d['asdf'] = '1234'
d['qwer'] = '5678'
return d