PIG UDF in JAVA ERROR 1070

て烟熏妆下的殇ゞ 提交于 2019-12-11 03:27:58

问题


I have created UDF_UPPER.jar file in /home/GED385/pigScripts.

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

But while executing the pig i am getting below error.

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 scripts:

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;

回答1:


What java package does your UPPER class belong to?

You will need to qualify your UPPER class with its package name in order for pig to find it. You do not need to reference the jar file name.

So if your UPPER class belonged to com.blah

You would write:

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);



回答2:


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

This tells me that piggybank and your jar are never getting actually imported.

My guess is that this is related to you are giving an absolute path for the jar files.

Instead, just do REGISTER UDF_UPPER.jar.




回答3:


According to following output,

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

UPPER.java has no package named 'UDF_UPPER'.

And in error 1070 : you are trying to import UPPER class inside UDF_UPPER package.

UDF_UPPER.UPPER means "<package name>.<class name>"

But as there is no UDF_UPPER package in your jar, so use only UPPER in pig script as below :

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

Hope, it solves your problem.



来源:https://stackoverflow.com/questions/13637391/pig-udf-in-java-error-1070

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!