Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

defining datatype in Pig

avatar

Im new to pig script to pardon me if my question is lame. I know that we can define a datatype for each atom in pig while loading it from a file. But is there a way we can define the datatype after taking a subset of it?

Example:

data = load 'mydata.csv' using PigStrogae(',') AS (col1:int, col2:int);

subsetdata = foreach data generate col1; --> Here i need to define the col1 as int . Is there a way to feed it?

1 ACCEPTED SOLUTION

avatar
Master Mentor

col1 is already int based on your schema in load statement. You can check with

describe data;

If you want to change type with generate, you can do so like this

X = FOREACH A GENERATE c1 AS x1:int;

View solution in original post

1 REPLY 1

avatar
Master Mentor

col1 is already int based on your schema in load statement. You can check with

describe data;

If you want to change type with generate, you can do so like this

X = FOREACH A GENERATE c1 AS x1:int;