pig-user  

Re: QuotedString and escaping Quotes

Iván de Prado
Mon, 22 Sep 2008 01:28:18 -0700

Many thanks!

Iván de Prado Alonso    
www.ivanprado.es

El vie, 19-09-2008 a las 10:38 -0700, Alan Gates escribió:
> Alright, I stand corrected.  We did commit a patch to fix this a little 
> while ago.  Do you have the latest stuff from top of trunk.  The 
> definition is now:
> 
> TOKEN : { <QUOTEDSTRING :  "'"
> (   (~["'","\\","\n","\r"])
>   | ("\\"
>       ( ["n","t","b","r","f","\\","'"] )
>     
> )                                                                          
>   | ("\\u"
>         ["0"-"9","A"-"F","a"-"f"]
>         ["0"-"9","A"-"F","a"-"f"]
>         ["0"-"9","A"-"F","a"-"f"]
>         ["0"-"9","A"-"F","a"-"f"]
>     )
> )*     
> "'"> }
> 
> so \' should work.
> 
> Alan.
> 
> Alan Gates wrote:
> > At this point the pig scanner does not escape strings.  If you want to 
> > add backslash escaping I think that would be great.
> >
> > Alan.
> >
> > Iván de Prado wrote:
> >> Hello,
> >> I am having a problem when giving parameters to a load function that
> >> loads data from a database. It receives a SQL query as parameter.
> >> Something like that:
> >>
> >> A = LOAD 'dbparams.cfg' USING  DBPigStorage('select if(field is null,
> >> \'null\',field) from table');
> >>
> >> But I am having a problem with quotes. I don't know how to escape quotes
> >> in order to insert them into a quotedString.
> >> I have taken a look to the grammar file:
> >>
> >> <quotedstring> := "'"<string>"'"
> >>
> >> But doesn't say nothing about string and escaping. Can I escape the
> >> quotes in a quotedstring using "\'"?
> >> If they are not any escaping in quoted strings, I propose to add
> >> java-like escaping with "\".
> >> Any other solution?
> >>
> >> Thanks, Iván de Prado Alonso
> >> www.ivanprado.es
> >>
> >>
> >>