Pig脚本无法注册UDF

2024-09-30 22:22:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个简单的Pig脚本,它使用了我创建的Python UDF。如果我删除了UDF部分,脚本将很好地完成。但是当我试图注册我的自定义项时,我得到了以下错误:

ERROR 2997: Encountered IOException. File pig_test/py_udf_substr.py does not exist

这是我的自定义项:

^{pr2}$

这是我的猪剧本:

REGISTER 'pig_test/py_udf_substr.py' USING jython as pyudf;

A = load 'pig_test/sf.txt' using PigStorage(',')
as (Unique_flight_ID,Year,Month,Day,DOW,
Scheduled_departure_time,Scheduled_arrival_time,
Airline,Flight_number,Tail_number,Plane_model,
Seat_configuration,Departure_delay,Origin_airport,
Destination_airport,Distance_travelled,Taxi_time_in,
Taxi_time_out,Cancelled,Cancellation_code,target);

B = FOREACH A GENERATE Unique_flight_ID, pyudf.get_fistsn($0,3);

DUMP B;

我用顺化来对付猪。数据和自定义项都在同一个HDFS位置(pig_test)。在


Tags: pytest脚本idnumbertimeasflight
2条回答

在编辑器中,您可以单击Properties,然后Resources并选择py_udf_substr.py作为file?在

然后在你的脚本中,只需:

REGISTER 'py_udf_substr.py' USING jython as pyudf;

根据您得到的错误,问题不在于脚本。它的IOException-框架无法读取UDF。您可以尝试给出UDF的完整路径,看看是否有效。使用新的终端尝试使用cat命令打开文件,看看路径是否正确。在

ERROR 2997: Encountered IOException. File pig_test/py_udf_substr.py does not exist

相关问题 更多 >