Author: pradeepkth
Date: Mon May  3 16:21:00 2010
New Revision: 940502

URL: http://svn.apache.org/viewvc?rev=940502&view=rev
Log:
PIG-740: Incorrect line number is generated when a string with double quotes is 
used instead of single quotes and is passed to UDF (pradeepkth)

Modified:
    hadoop/pig/trunk/CHANGES.txt
    
hadoop/pig/trunk/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj
    hadoop/pig/trunk/test/org/apache/pig/test/TestGrunt.java

Modified: hadoop/pig/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/CHANGES.txt?rev=940502&r1=940501&r2=940502&view=diff
==============================================================================
--- hadoop/pig/trunk/CHANGES.txt (original)
+++ hadoop/pig/trunk/CHANGES.txt Mon May  3 16:21:00 2010
@@ -53,6 +53,9 @@ PIG-1309: Map-side Cogroup (ashutoshc)
 
 BUG FIXES
 
+740 : Incorrect line number is generated when a string with double quotes is
+used instead of single quotes and is passed to UDF (pradeepkth)
+
 1378: har url not usable in Pig scripts (pradeepkth)
 
 PIG-1395:  Mapside cogroup runs out of memory (ashutoshc)

Modified: 
hadoop/pig/trunk/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj?rev=940502&r1=940501&r2=940502&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj 
(original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj 
Mon May  3 16:21:00 2010
@@ -309,7 +309,7 @@ TOKEN_MGR_DECLS : {
 
 <IN_BLOCK> MORE :
 {
-       <"\""> {prevState = IN_BLOCK;} : IN_STRING
+       <"\""> {prevState = IN_BLOCK;} : IN_DOUBLE_QUOTED_STRING
 |      <(" " | "\t")+["A","a"]["S","s"](" " | "\t")+ > {prevState = IN_BLOCK;} 
: SCHEMA_DEFINITION
 |   <(" " | 
"\t")+["G","g"]["E","e"]["N","n"]["E","e"]["R","r"]["A","a"]["T","t"]["E","e"]("
 " | "\t")+> {prevState = IN_BLOCK;} : GENERATE
 |      <"{"> {pigBlockLevel++;}
@@ -322,6 +322,14 @@ TOKEN_MGR_DECLS : {
 |       <(~[])>
 }
 
+<IN_DOUBLE_QUOTED_STRING> MORE :
+{
+    <"\\\"">
+|   <"\""> { SwitchTo(prevState);}
+|   <("\n" | "\r" | "\r\n")> {secondary_prompt();}
+|   <(~[])>
+}
+
 <PIG_END> TOKEN :
 {
         <PIG: ""> {    matchedToken.image = image.toString();

Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestGrunt.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestGrunt.java?rev=940502&r1=940501&r2=940502&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestGrunt.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestGrunt.java Mon May  3 
16:21:00 2010
@@ -858,4 +858,26 @@ public class TestGrunt extends TestCase 
             assertTrue(results[i] == 0);
         }
     }
+    
+    // Test case for PIG-740 to report an error near the double quotes rather
+    // than an unrelated EOF error message
+    public void testBlockErrMessage() throws Throwable {
+        PigServer server = new PigServer(ExecType.MAPREDUCE, 
cluster.getProperties());
+        PigContext context = server.getPigContext();
+
+        String script = "A = load 'inputdata' using PigStorage() as ( 
curr_searchQuery );\n" +
+                       "B = foreach A { domain = 
CONCAT(curr_searchQuery,\"^www\\.\");\n" +
+                       "        generate domain; };\n";
+        ByteArrayInputStream cmd = new ByteArrayInputStream(script.getBytes());
+        InputStreamReader reader = new InputStreamReader(cmd);
+
+        Grunt grunt = new Grunt(new BufferedReader(reader), context);
+
+        try {
+        grunt.exec();
+        } catch(Error e) {
+            e.printStackTrace();
+            assertTrue(e.getMessage().contains("Encountered: \"^\" (94), after 
: \"\\\"\""));
+        }
+    }
 }


Reply via email to