由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
DataSciences版 - Pig UDF written in Python
相关主题
请问大家有没有直接用java全程写mapreduce的程序的?HIVE load CSV 问题请教
pig能做iterative的问题吗?请问如何用JDBC连接R和Hive (转载)
求教! how to run python programs on a hadoop clusterDS需要会的手艺 真不少
说说浅学ML的感受请教各位DS大拿
我觉得关于datascience最近看到的几个有价值的贴板上R高手多,包子求R数据输出到CSV方法
data scientist position诚心请教Spark EMR配置
ds要刷leecode吗,请教一个Big Data/Analysis 方面的设计问题
hive 里面的UDF会被几个node同时运行么?免费讲座: JSON in SQL2016 (转载)
相关话题的讨论汇总
话题: pig话题: python话题: udf话题: error话题: jython
进入DataSciences版参与讨论
1 (共1页)
r*****d
发帖数: 346
1
我又要请教大家一个问题了,,
我在试验怎么用Pig UDF in Python,
当运行:
grunt>register '/absolute_path_to/my_first_udf.py' using jython as myfuncs;
得到:
ERROR org.apache.pig.tools.grunt.Grunt - ERROR 2999: Unexpected internal
error. null
Details at pig_1400616625260.log
我查了下log file, 里面写着:
Pig Stack Trace
---------------
ERROR 2999: Unexpected internal error. null
SyntaxError: ("mismatched input '' expecting DEDENT", ('', 5,
20, ' return decoratorn'))
我比较确定.py file没问题。
谁知道这是怎么回事?谢谢了!
k****o
发帖数: 76
2
have you register jython.jar before registering python script?
or adding jython.jar path to your PIG_CLASSPATH environment?
same thing, and see if it works

【在 r*****d 的大作中提到】
: 我又要请教大家一个问题了,,
: 我在试验怎么用Pig UDF in Python,
: 当运行:
: grunt>register '/absolute_path_to/my_first_udf.py' using jython as myfuncs;
: 得到:
: ERROR org.apache.pig.tools.grunt.Grunt - ERROR 2999: Unexpected internal
: error. null
: Details at pig_1400616625260.log
: 我查了下log file, 里面写着:
: Pig Stack Trace

r*****d
发帖数: 346
3
Thank you.
i did register jython.jar and did add jython.jar path to my PIG_CLASSPATH
environment.
if i did not do them, it would be a *different* error code, which would be:
Pig Stack Trace
---------------
ERROR 2998: Unhandled internal error. org/python/core/PyObject
java.lang.NoClassDefFoundError: org/python/core/PyObject
at org.apache.pig.scripting.jython.JythonScriptEngine.
registerFunctions(JythonScriptEngine.java:304)
...

【在 k****o 的大作中提到】
: have you register jython.jar before registering python script?
: or adding jython.jar path to your PIG_CLASSPATH environment?
: same thing, and see if it works

r*****d
发帖数: 346
4
could there be a compatibility issue between jython and pig?

【在 k****o 的大作中提到】
: have you register jython.jar before registering python script?
: or adding jython.jar path to your PIG_CLASSPATH environment?
: same thing, and see if it works

r*****d
发帖数: 346
5
问题终于孑孓了。。
问题出在原来的jython是老版本,2.5.1+
我下载了最新的版本,2.5.3
然后把原来的register jython.jar跟PIG_CLASSPATH都换成新的就好了
老版本可以用来单独运行python script,
但是不能放到register 'my_udf.py' using jython as myfuncs;
因为跟用的Pig版本不兼容
就酱紫
r*****d
发帖数: 346
6
又有一个问题,需要import a python module怎么办?
比如import json
执行pig script的时候得到:
ImportError: no module named json
json这个module在那里,
假设这个python script的名字是test.py
执行python test.py没问题
但是执行jython test.py就也得到ImportError: no module named json
非常感谢!

【在 r*****d 的大作中提到】
: 我又要请教大家一个问题了,,
: 我在试验怎么用Pig UDF in Python,
: 当运行:
: grunt>register '/absolute_path_to/my_first_udf.py' using jython as myfuncs;
: 得到:
: ERROR org.apache.pig.tools.grunt.Grunt - ERROR 2999: Unexpected internal
: error. null
: Details at pig_1400616625260.log
: 我查了下log file, 里面写着:
: Pig Stack Trace

j*******g
发帖数: 331
7
UDF里面的package必须要是implemented by Jyphon才可以, 有些Cython编译的就不行

【在 r*****d 的大作中提到】
: 又有一个问题,需要import a python module怎么办?
: 比如import json
: 执行pig script的时候得到:
: ImportError: no module named json
: json这个module在那里,
: 假设这个python script的名字是test.py
: 执行python test.py没问题
: 但是执行jython test.py就也得到ImportError: no module named json
: 非常感谢!

l*******m
发帖数: 1096
8
need to test in jython.
BTW, using java is much much better with hadoop. Json parsing in java is 10-
time faster compared to python.

【在 r*****d 的大作中提到】
: 又有一个问题,需要import a python module怎么办?
: 比如import json
: 执行pig script的时候得到:
: ImportError: no module named json
: json这个module在那里,
: 假设这个python script的名字是test.py
: 执行python test.py没问题
: 但是执行jython test.py就也得到ImportError: no module named json
: 非常感谢!

r*****d
发帖数: 346
9
More details please? Thank you very much.

【在 j*******g 的大作中提到】
: UDF里面的package必须要是implemented by Jyphon才可以, 有些Cython编译的就不行
r*****d
发帖数: 346
10
i don't know how to code in java..
yeah i was convinced today that UDFs should be coded in java

10-

【在 l*******m 的大作中提到】
: need to test in jython.
: BTW, using java is much much better with hadoop. Json parsing in java is 10-
: time faster compared to python.

相关主题
data scientist positionHIVE load CSV 问题请教
ds要刷leecode吗,请问如何用JDBC连接R和Hive (转载)
hive 里面的UDF会被几个node同时运行么?DS需要会的手艺 真不少
进入DataSciences版参与讨论
r*****d
发帖数: 346
11
update:
如果python udf 不 import any module, 没问题,
但是,奇葩的是
一个python script(里面有import ast), say test.py
执行python test.py没问题
执行jython test.py也没问题
但是,,
如果在Pig script里register test.py using jython
得到ImportError: No module named ast

【在 r*****d 的大作中提到】
: 又有一个问题,需要import a python module怎么办?
: 比如import json
: 执行pig script的时候得到:
: ImportError: no module named json
: json这个module在那里,
: 假设这个python script的名字是test.py
: 执行python test.py没问题
: 但是执行jython test.py就也得到ImportError: no module named json
: 非常感谢!

l*******m
发帖数: 1096
12
如果你就是在pig读json. 用elephant bird的json loader就好,不用java coding
download如下jar(google 他们的jar下载,不要编译整个repositery, 不容易)
register /path/to/json-simple.jar;
register /path/to/elephant-bird-core.jar;
register /path/to/elephant-bird-pig.jar;
一个完整的example
https://github.com/kevinweil/elephant-bird/blob/master/examples/src/main/pig
/nested_json_get_distinct_items_from_nested_array.pig

【在 r*****d 的大作中提到】
: i don't know how to code in java..
: yeah i was convinced today that UDFs should be coded in java
:
: 10-

j*******g
发帖数: 331
13
another thing I can think of is you probably should make sure all data nodes
has this package installed, did you test on every data node you gonna use?

【在 r*****d 的大作中提到】
: update:
: 如果python udf 不 import any module, 没问题,
: 但是,奇葩的是
: 一个python script(里面有import ast), say test.py
: 执行python test.py没问题
: 执行jython test.py也没问题
: 但是,,
: 如果在Pig script里register test.py using jython
: 得到ImportError: No module named ast

r*****d
发帖数: 346
14
嗯,是某一个field是json而不是整个table所以不是load function这边。
anyway, 我在学java coding, 目标就是写写udf酱紫

pig

【在 l*******m 的大作中提到】
: 如果你就是在pig读json. 用elephant bird的json loader就好,不用java coding
: download如下jar(google 他们的jar下载,不要编译整个repositery, 不容易)
: register /path/to/json-simple.jar;
: register /path/to/elephant-bird-core.jar;
: register /path/to/elephant-bird-pig.jar;
: 一个完整的example
: https://github.com/kevinweil/elephant-bird/blob/master/examples/src/main/pig
: /nested_json_get_distinct_items_from_nested_array.pig

r*****d
发帖数: 346
15
hopefully it is not this complicated.. i treat data nodes as encapsulation..

nodes

【在 j*******g 的大作中提到】
: another thing I can think of is you probably should make sure all data nodes
: has this package installed, did you test on every data node you gonna use?

l*******m
发帖数: 1096
16
elephant bird有jsonStringToMap的UDF. 当然自己写,也没几行

【在 r*****d 的大作中提到】
: 嗯,是某一个field是json而不是整个table所以不是load function这边。
: anyway, 我在学java coding, 目标就是写写udf酱紫
:
: pig

j*******g
发帖数: 331
17
data node might be inaccurate, but look at this
http://stackoverflow.com/questions/7831649/how-do-i-make-hadoop

..

【在 r*****d 的大作中提到】
: hopefully it is not this complicated.. i treat data nodes as encapsulation..
:
: nodes

t******g
发帖数: 2253
18
lz是HH?
r*****d
发帖数: 346
19
谢谢大家!迟些时候发包子。
1 (共1页)
进入DataSciences版参与讨论
相关主题
免费讲座: JSON in SQL2016 (转载)我觉得关于datascience最近看到的几个有价值的贴
[Pig Progamming] Pig Latin join problemdata scientist position
各位说的编程,到底是啥ds要刷leecode吗,
学习Pig Latinhive 里面的UDF会被几个node同时运行么?
请问大家有没有直接用java全程写mapreduce的程序的?HIVE load CSV 问题请教
pig能做iterative的问题吗?请问如何用JDBC连接R和Hive (转载)
求教! how to run python programs on a hadoop clusterDS需要会的手艺 真不少
说说浅学ML的感受请教各位DS大拿
相关话题的讨论汇总
话题: pig话题: python话题: udf话题: error话题: jython