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 >> error to generate a map?


Copy link to this message
-
Re: error to generate a map?
thanks Alan

the problem does not seem to be string

if I have

a = load 'a' as x:chararray;

b = foreach a generate (['mykey'#x]);

it would fail
while if u change the x to 1    it works fine
the same issue of constants vs var is also seen in the following example
for bag:

grunt>  b = foreach a generate {(x),(x)} as  bb:bag{T:tuple ( yy:int)};
2012-06-20 15:54:08,053 [main] ERROR org.apache.pig.tools.grunt.Grunt -
ERROR 1200: <line 5, column 25>  rule null_keyword failed predicate:
{input.LT(1).getText().equalsIgnoreCase("NULL")}?
Details at logfile:
/crypt/yyang_home/work/matching/ML-places-matcher/control_flows/match_suspects/pig_1340232590787.log
grunt>  b = foreach a generate {(1),(1)} as  bb:bag{T:tuple ( yy:int)};

the second one succeeds
Thanks
Yang

On Fri, Jun 15, 2012 at 8:58 AM, Alan Gates <[EMAIL PROTECTED]> wrote:

> Maps require string keys.  So it should read ['222'#1].
>
> Alan.
>
> On Jun 7, 2012, at 8:51 PM, Yang wrote:
>
> > I ran the following simple pig script
> >
> >
> > a = load 'a';
> >
> > b = foreach a generate [222#1];
> >
> > dump b;
> >
> >
> > but it gave the following error
> >
> > $ pig -x local  a.pig
> > 2012-06-07 20:49:13,039 [main] INFO  org.apache.pig.Main - Logging error
> > messages to:
> >
> /crypt/yyang_home/work/matching/ML-places-matcher/control_flows/match_suspects/pig_1339127353036.log
> > 2012-06-07 20:49:13,168 [main] INFO
> > org.apache.pig.backend.hadoop.executionengine.HExecutionEngine -
> > Connecting to hadoop file system at: file:///
> > 2012-06-07 20:49:13,692 [main] ERROR org.apache.pig.tools.grunt.Grunt -
> > ERROR 1200: <file a.pig, line 3, column 23>  Syntax error, unexpected
> > symbol at or near '['
> >
> >
> >
> > but this script is basically the same as the one copied from manual:
> > http://pig.apache.org/docs/r0.9.2/basic.html
> >
> > A = LOAD 'data' USING MyStorage() AS (T: tuple(name:chararray, age:
> int));
> > B = FILTER A BY T == ('john', 25);
> > D = FOREACH B GENERATE T.name, [25#5.6], {(1, 5, 18)};
> >
> >
> >
> > how could I fix it?
> >
> >
> >
> > thanks!
> >
> > yang
>
>
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