pig-udf-in-java错误1070

gg0vcinb  于 2021-06-24  发布在  Pig
关注(0)|答案(3)|浏览(413)

我创造了 UDF_UPPER.jar 文件输入 /home/GED385/pigScripts .

[GED385@snshadoope1 pigScripts]$ jar tf /home/GED385/pigScripts/UDF_UPPER.jar | grep UPPER
UPPER.class

但在执行Pig我得到下面的错误。

grunt> exec digital_web_trkg_9.pig
2012-11-30 00:15:32,027 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1070: Could not resolve UDF_UPPER.UPPER using imports: [, org.apache.pig.builtin., org.apache.pig.impl.builtin.]
Details at logfile: /data/1/GED385/pigScripts_digital/pig_1354233151486.log

Pig脚本:

REGISTER /usr/lib/pig/contrib/piggybank/java/piggybank.jar;
REGISTER /home/GED385/pigScripts/UDF_UPPER.jar;

A = LOAD '/user/GED385/digital/scrn_rsln_id_cln.dat' USING PigStorage('|')
                  AS (web_vstr_scrn_rsln_id:int,web_vstr_scrn_rsln_desc :chararray, edw_publn_id:chararray);

B = LOAD '/user/GED385/digital/scrn_rsln_id1_cln.dat' USING PigStorage('|')
                  AS (web_vstr_scrn_rsln_id:int,web_vstr_scrn_rsln_desc :chararray, edw_publn_id:chararray);

H = LOAD '/user/GED385/digital/scrn_rsln_id_base_unload_cln.dat' USING PigStorage('|')
                  AS (web_vstr_scrn_rsln_id_1:int,web_vstr_scrn_rsln_desc :chararray, edw_publn_id:chararray);

J = GROUP H BY edw_publn_id;

K = FOREACH J GENERATE group,  MAX(H.web_vstr_scrn_rsln_id_1);

C = UNION A, B;

D = FILTER C BY web_vstr_scrn_rsln_desc is not null;

E = DISTINCT D;

F = JOIN E BY web_vstr_scrn_rsln_desc LEFT , H BY web_vstr_scrn_rsln_desc;

I = FILTER F BY H::web_vstr_scrn_rsln_id_1 is null;

--G = FOREACH I GENERATE H::web_vstr_scrn_rsln_id_1,E::web_vstr_scrn_rsln_desc,E::edw_publn_id;
G = FOREACH I GENERATE K.$1+1,E::web_vstr_scrn_rsln_desc,E::edw_publn_id,UDF_UPPER.UPPER(E::web_vstr_scrn_rsln_desc);

--L = JOIN G BY $2 LEFT , K BY $0;

DUMP G;
yi0zb3m4

yi0zb3m41#

根据以下输出,

[GED385@snshadoope1 pigScripts]$ jar tf /home/GED385/pigScripts/UDF_UPPER.jar | grep UPPER
UPPER.class

java没有名为“udf\u upper”的包。
在错误1070中:您试图在udf\ U upper包中导入上层类。 UDF_UPPER.UPPER 手段 "<package name>.<class name>" 但是由于您的jar中没有udf\u上包,所以只使用 UPPER 在Pig的脚本如下:

G = FOREACH I GENERATE K.$1+1,E::web_vstr_scrn_rsln_desc,E::edw_publn_id,UPPER(E::web_vstr_scrn_rsln_desc);

希望它能解决你的问题。

tyky79it

tyky79it2#

using imports: [, org.apache.pig.builtin., org.apache.pig.impl.builtin.]

这告诉我,小Pig罐和你的jar永远不会真正进口。
我猜这与您为jar文件提供绝对路径有关。
相反,只要做 REGISTER UDF_UPPER.jar .

r6hnlfcb

r6hnlfcb3#

你的上层阶级属于哪个java包?
为了让pig找到它,您需要用它的包名限定您的上层类。您不需要引用jar文件名。
如果你的上层阶级属于 com.blah 你会写:

G = FOREACH I GENERATE K.$1+1,E::web_vstr_scrn_rsln_desc,E::edw_publn_id,com.blah.UPPER(E::web_vstr_scrn_rsln_desc);

相关问题