[ 
https://issues.apache.org/jira/browse/PIG-377?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13007065#comment-13007065
 ] 

Xuefu Zhang commented on PIG-377:
---------------------------------

The issue is caused by the fact that we use string literal for both string 
constant and regular expression. They have different escape requirements. \s is 
legal for java regex, but illegal for a string constant. Pig grammar needs to 
be changed to fix this.

> Grunt parser doesn't handle escape codes correctly
> --------------------------------------------------
>
>                 Key: PIG-377
>                 URL: https://issues.apache.org/jira/browse/PIG-377
>             Project: Pig
>          Issue Type: Bug
>          Components: grunt
>         Environment: Pig Trunk  01-Aug-2008
> Hadoop 17.1
> Linux Ubuntu
>            Reporter: Rafael Turk
>            Assignee: Xuefu Zhang
>            Priority: Minor
>             Fix For: 0.9.0
>
>
> Grunt parser doesn't handle escape codes correctly such as \s \n \\..
> Exemple, using:
>  raw_filtered = FILTER raw BY ngram matches '^[a-zA-Z0-9\s]$';
> OR
>  raw_filtered = FILTER raw BY ngram matches "^[a-zA-Z0-9\s]$";
> I get the following error:
> org.apache.pig.impl.logicalLayer.parser.TokenMgrError: Lexical error at line 
> 1, column 57.  Encountered: "s" (115), after : "\'^[a-zA-Z0-9\\"
>         at 
> org.apache.pig.impl.logicalLayer.parser.QueryParserTokenManager.getNextToken(QueryParserTokenManager.java:1623)
>         at 
> org.apache.pig.impl.logicalLayer.parser.QueryParser.jj_consume_token(QueryParser.java:4744)
>         at 
> org.apache.pig.impl.logicalLayer.parser.QueryParser.PUnaryCond(QueryParser.java:1117)
>         at 
> org.apache.pig.impl.logicalLayer.parser.QueryParser.PAndCond(QueryParser.java:1055)
>         at 
> org.apache.pig.impl.logicalLayer.parser.QueryParser.POrCond(QueryParser.java:1005)
>         at 
> org.apache.pig.impl.logicalLayer.parser.QueryParser.PCond(QueryParser.java:973)
>         at 
> org.apache.pig.impl.logicalLayer.parser.QueryParser.FilterClause(QueryParser.java:941)
>         at 
> org.apache.pig.impl.logicalLayer.parser.QueryParser.BaseExpr(QueryParser.java:686)
>         at 
> org.apache.pig.impl.logicalLayer.parser.QueryParser.Expr(QueryParser.java:512)
>         at 
> org.apache.pig.impl.logicalLayer.parser.QueryParser.Parse(QueryParser.java:362)
>         at 
> org.apache.pig.impl.logicalLayer.LogicalPlanBuilder.parse(LogicalPlanBuilder.java:47)
>         at org.apache.pig.PigServer.registerQuery(PigServer.java:275)
>         at 
> org.apache.pig.tools.grunt.GruntParser.processPig(GruntParser.java:475)
>         at 
> org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:233)
>         at 
> org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:81)
>         at org.apache.pig.tools.grunt.Grunt.exec(Grunt.java:60)
>         at org.apache.pig.Main.main(Main.java:294)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to