1

我有一个简单的 Pig 脚本,它使用我创建的 Python UDF。如果我删除 UDF 部分,脚本就可以完成。但是当我尝试注册我的 UDF 时,我收到以下错误:

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

这是我的UDF:

@outputSchema("chararray")
def get_fistsn(data,n):
    return data[:n]

这是我的猪脚本:

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;

我正在使用 HUE 来运行 Pig。数据和 UDF 都在同一个 HDFS 位置 (pig_test)。

4

2 回答 2

1

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

ERROR 2997: Encountered IOException. File pig_test/py_udf_substr.py does not exist
于 2015-04-08T19:31:47.380 回答
0

在编辑器中,您可以单击Properties,然后Resources选择py_udf_substr.pyasfile吗?

然后在您的脚本中,只需执行以下操作:

使用 jython 作为 pyudf 注册“py_udf_substr.py”;

于 2015-04-09T04:23:24.203 回答