Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Plain View
Pig >> mail # user >> why the foreach nested form can't work?


+
勇胡 2011-07-19, 13:00
Copy link to this message
-
Re: why the foreach nested form can't work?
I think it's because 'A.score' is a bag but Pig needs a reference to a
field in the tuples. This worked for me:

A = LOAD 'foo.tsv' AS (name:chararray, no:int, score: int);
B = GROUP A BY no;
C = FOREACH B {
      D = FILTER A BY score > 80;
      GENERATE FLATTEN(D.(name, score));
    };
DUMP C;

on the following data:

$: cat foo.tsv
henrietta 1 25
sally 1 82
fred 3 120
elsie 4 45

yields:

(sally,82)
(fred,120)

Does that work for you?

--jacob
@thedatachef

On Tue, 2011-07-19 at 15:00 +0200, 勇胡 wrote:
> A = LOAD '/home/test/student.txt' AS (name:chararray, no:int, score:
> int);
> B = GROUP A BY no;
> C =  FOREACH B {
>     D = FILTER A BY A.score > 80;
>     GENERATE D.name, D.score;}
> DUMP C;
+
勇胡 2011-07-19, 14:05
+
Gianmarco 2011-07-19, 14:19
+
Jacob Perkins 2011-07-19, 14:26
+
勇胡 2011-07-20, 09:33
+
Daniel Dai 2011-07-20, 17:59
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB