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 Threaded View
Pig >> mail # user >> Get field from bag with constraints from same relation


Copy link to this message
-
Get field from bag with constraints from same relation
Hi there,

I have the following data

4 {(1,abc),(2,cde),(5,efg)}
2 {(1,foo),(2,bar),(5,baz)}
7 {(1,bounce),(2,frotz),(5,trotz)}

what I finally want to achieve is a list of all strings related to the
largest number in the tuple that is less-equal the first number in
the row. i.e.:

(4,cde)
(2,bar)
(5,trotz)

I was thinking about filtering the data first in a foreach and then
extract the max of the resulting list (probably in the same foreach
block). But, I'm already stuck at:

data = load 'example_data'
     as (n: int, B: bag{(m: int, s: chararray)});
X = foreach data {
  A = filter B by m <= n;
  GENERATE n, A;
}

ERROR 1025:
<line 14, column 23> Invalid field projection. Projected field [n] does not exist in schema: m:int,s:chararray.

Any help highly appreciated.

Regards,
Thomas Bach.
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