Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

PIG tranform relations format after first load

avatar
Expert Contributor

Hey everyone,

My case today is a little weird for me cause according to me I'm running the right scripts but well anyways, the thing is that I need load a file with a char structure but then I need to delete the headers and set the right structure relation.

Here my code:

17463-transformed.png

Finally, I'm trying to perform a sum using this new structure but Pig always according with the log return an error casting the column with the new format as long for salary and int for the year so is like Pig won't be able to get the new structure.

17464-transformed.png

Error:

17465-transformed.png

Could some of our gurus let me know the right way to get a nice transformation and perform my scripts.

thanks so much

1 ACCEPTED SOLUTION

avatar

Instead of

year as (year:int)

try

(int) year as castedYear:int

View solution in original post

2 REPLIES 2

avatar

Instead of

year as (year:int)

try

(int) year as castedYear:int

avatar
Expert Contributor

Thanks so much @Lester Martin I appreciate your help now worked, I replaced my statement using yours and it worked.

salaries_cl = FOREACH salaries_fl GENERATE (int)year as year:int,$1,$2,$3, (long)salary as salary:long;

Weird why the other one didn't work but well thanks so much.