Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Pig >> mail # user >> Escaping Dollar Sign in Map in Pig 0.10


Copy link to this message
-
Re: Escaping Dollar Sign in Map in Pig 0.10
Hi Eli,

I tried to reproduce your problem. What I found is that the behavior is
different when using Grunt shell and running it as a script.

* Input file *

cheolsoo@localhost:~/workspace/pig-svn $cat 1.txt
$id,a

* Grunt shell *

The $ with no backslash works:

grunt> A = LOAD '1.txt' USING PigStorage(',') AS (k:chararray, v:chararray);
grunt> B = FOREACH A GENERATE TOMAP(k, v) AS M;
grunt> C = FOREACH B GENERATE M#'$id';
grunt> DUMP C;
(a)

* Script *

The $ with a single backslash works:

cheolsoo@localhost:~/workspace/pig-svn $cat test.pig
A = LOAD '1.txt' USING PigStorage(',') AS (k:chararray, v:chararray);
B = FOREACH A GENERATE TOMAP(k, v) AS M;
C = FOREACH B GENERATE M#'\$id';
DUMP C;

cheolsoo@localhost:~/workspace/pig-svn $./bin/pig -x local test.pig
(a)

Please let me know if you see different results.

Thanks,
Cheolsoo
On Mon, Jan 14, 2013 at 7:40 AM, Eli Finkelshteyn <[EMAIL PROTECTED]>wrote:

> Any other ideas? Still no solution on this.
>
> Eli
>
> On Jan 10, 2013, at 7:33 PM, Dmitriy Ryaboy wrote:
>
> > Two back slashes?
> >
> >
> > On Thu, Jan 10, 2013 at 6:01 PM, Eli Finkelshteyn <[EMAIL PROTECTED]
> >wrote:
> >
> >> This wasn't a problem in 0.9.2, but in 0.10, when I try to access a key
> in
> >> a map that has a dollar sign in it, I get hammered with errors that I
> >> haven't defined the variable. Specifically:
> >>
> >>   blah = FOREACH meh GENERATE source, json_post_id#'$id' AS post_id;
> >>
> >> returns
> >>
> >>   Undefined parameter : id
> >>
> >> That's fine and makes sense, but when I amend it to:
> >>
> >>   blah = FOREACH meh GENERATE source, json_post_id#'\$id' AS post_id;
> >>
> >> I get:
> >>
> >>   Unexpected character '$'
> >>
> >> Ideas?
> >>
> >> Thanks!
> >> Eli
> >>
>
>