USB
USB

Reputation: 6139

PigStorage along with FOREACH statement

While doing FOREACH I need to give a delimiter ","

A = FOREACH interdata generate $0,$6 USING PigStorage(','); 

I tried but showing

mismatched input 'using' expecting SEMI_COLON

But how can I give delimiter along with FOREACH statement.Is there any other way to do the same Thanks in Advance.

Upvotes: 0

Views: 107

Answers (2)

Jerome Serrano
Jerome Serrano

Reputation: 1855

I guess you're trying to store the content of A into a coma separated file and for that you need to use a store statement: STORE alias INTO 'directory' [USING function]. You cannot do it with a foreach statement alone.

Example

A = FOREACH interdata generate $0,$ 6;
store A into 'output' USING PigStorage(',');

Upvotes: 1

robthewolf
robthewolf

Reputation: 7624

I am not sure why you are trying to give a delimiter here. PigStorage is used with a load statement. So it should be something like.

interdata = load '' using PigStorage(',');

A = foreach interdata generate $0,$6;

Upvotes: 0

Related Questions