Uselesssss
Uselesssss

Reputation: 2133

Error while excecuting UDF in PIG

I am trying to run my first UDF using the example

http://wiki.apache.org/pig/UDFManual. Now i have my FirstUdf.jar,myscript.pig both in same folder

My myscript.pig is as follows

  REGISTER FirstUdf.jar; A = LOAD '/home/vishal/exampleforPIG1' AS
 (exchange: chararray, symbol: chararray, date: int,value:float);  

B =FOREACH A GENERATE myudfs.UPPER(symbol);

DUMP B;

Now when i am giving the following command to run my script it gives me the following error

Command--

java -cp FirstUdf.jar home/vishal/FirstUdf.jar -x local myscript.pig

Following Error--

ERROR 1000: Error during parsing. Encountered " "java "" at line 1, column 1.

Am i giving the command wrong or what is the issue

Upvotes: 0

Views: 142

Answers (1)

Lorand Bendig
Lorand Bendig

Reputation: 10650

You may try the followings:

Hardcode the path to the custom UDF you have:

REGISTER '/path/to/FirstUdf.jar';
DEFINE myUDF com.example.MyUDF();
...

Then:
pig -f myscript.pig -x local

...or pass it as a command line argument:

REGISTER '$UDF_PATH/FirstUdf.jar';
DEFINE myUDF com.example.MyUDF();
...

Then:
pig -f myscript.pig -param UDF_PATH=/path/to -x local

Upvotes: 0

Related Questions