Search code examples
javaapache-pig

Importing a java file to pig


rawGSODData = LOAD '/usr/local/Cellar/pig/0.12.0/gsod_2016/999999-93816-2016.op.gz' USING org.apache.pig.piggybank.storage.FixedWidthLoader('
1-6, 
8-12, 
15-18,
19-22,
25-30,
32-33,
36-41,
43-44,
47-52,
54-55,
58-63,
65-66,
69-73,
75-76,
79-83,
85-86,
89-93,
96-100,
103-108,
109-109,
111-116,
117-117,
119-123,
124-124,
126-130,
133-138', 
'SKIP_HEADER');

When I try to run this code I will get an error saying

 ERROR 1070: Could not resolve org.apache.pig.piggybank.storage.FixedWidthLoader using imports: [, java.lang., org.apache.pig.builtin., org.apache.pig.impl.builtin.]

I have the file FixedWidthLoader.java file in the directory

/usr/local/Cellar/pig/0.12.0/build/classes/org/apache/pig/piggybank/storage

Please help me with this error


Solution

  • Where is the piggybank.jar located ? Ensure you have registered piggybank.jar in your Pig script.If not, add this to the top of your pig script.Ensure the path to piggybank.jar is correct.Below statement registers the jar file i.e. piggybank located in /usr/local/

    REGISTER '/usr/local/piggybank.jar';