Grokbase Groups Pig user July 2011
FAQ
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

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriespig, hadoop
postedJul 26, '11 at 2:21p
activeJul 26, '11 at 2:21p
posts1
users1
websitepig.apache.org

1 user in discussion

Norbert Burger: 1 post

People

Translate

site design / logo © 2021 Grokbase