Youngwoo,

It will work if you change the foreach statement to

r1 = FOREACH records GENERATE LOWER(input_line);

Otherwise Pig thinks that your intent is to use relation (‘records’) as scalar 
(this is a new feature of 0.8).

Thanks,
- Richard


On 1/18/11 10:36 PM, "김영우" <[email protected]> wrote:

Richard,

I found my mistakes. Your example works well with 'normal' relations(bag). but 
in my test code Pig did implicit casting from relations to scalars.

r1 = FOREACH records GENERATE LOWER(records.input_line);
STORE r1 INTO '$out';


I need to store 'r1' as a bag. How can I do this?

Thanks.

- Youngwoo?

2011년 1월 19일 오전 3:55, Richard Ding <[email protected]>님의 말:
The method you’re looking for is PigStats.result(String alias) which returns a 
OutputStats object.

Here is an example:

R = Pig.compile(...).bind(...).runSingle()
iter = R.result(“G”).iterator()
while iter.hasNext():
????t = iter.next()
????....

On 1/17/11 9:34 PM, "김영우" <[email protected] <http://[email protected]> > 
wrote:

Hi All,

I'm looking into embedding pig latin in a host language using pig trunk. so
far, basic features work fine for me. but I need to know how can I get
result tuples from the stored bag.
I need to apply some processing to each tuple from result bag. In wiki
http://wiki.apache.org/pig/TuringCompletePig , It seems 'getResults()'
method works like what I want. but I got an error like "returned PigStats
has no attribute 'getResults()' ..."

Any advice would be appreciated.

- Youngwoo



Reply via email to