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

Switch to Plain View
Pig >> mail # user >> REPLACE with backslash


Copy link to this message
-
REPLACE with backslash
Hi,

I'm little bit puzzled about REPLACE when there is backslash involved.

I want to replace all the "dir" in the string with "\\test\sub",

After a lot of try and error, I finally got it done, but I'm not sure why it is the case. Here's my code

A = load 'a.txt' as (name:chararray);
B = foreach A generate REPLACE(name,'dir','\\\\\\\\test\\\\sub');
dump B;

The thing I'm confused about is why do I need to use "\\\\" in order to generate a "\", can anyone explain the reason? I'm using pig 0.9.1.

Thanks.

Dan
+
Bill Graham 2012-09-07, 21:14
+
=?KOI8-U?B?96bUwcymyiD0yc... 2012-09-08, 07:39
+
Danfeng Li 2012-09-08, 20:44
+
=?KOI8-U?B?96bUwcymyiD0yc... 2012-09-09, 17:28