Author: knoguchi
Date: Tue Mar  1 15:51:52 2016
New Revision: 1733091

URL: http://svn.apache.org/viewvc?rev=1733091&view=rev
Log:
PIG-4818: Single quote inside comment in GENERATE is not being ignored 
(knoguchi)

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

Modified: pig/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1733091&r1=1733090&r2=1733091&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Tue Mar  1 15:51:52 2016
@@ -97,6 +97,8 @@ PIG-4639: Add better parser for Apache H
 
 BUG FIXES
 
+PIG-4818: Single quote inside comment in GENERATE is not being ignored 
(knoguchi)
+
 PIG-4814: AvroStorage does not take namenode HA as part of schema file url 
(daijy)
 
 PIG-4812: Register Groovy UDF with relative path does not work (daijy)

Modified: pig/trunk/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj
URL: 
http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj?rev=1733091&r1=1733090&r2=1733091&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj 
(original)
+++ pig/trunk/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj Tue 
Mar  1 15:51:52 2016
@@ -321,6 +321,18 @@ TOKEN_MGR_DECLS : {
         saveState(prevState);
         prevState = GENERATE;
      } : SCHEMA_DEFINITION
+|   <"--">
+    {
+        prevState = getState(prevState);
+        saveState(prevState);
+        prevState = GENERATE;
+    } : SINGLE_LINE_COMMENT
+|      <"/*">
+    {
+        prevState = getState(prevState);
+        saveState(prevState);
+        prevState = GENERATE;
+    } : MULTI_LINE_COMMENT
 |   <"'">
     {
         prevState = getState(prevState);

Modified: pig/trunk/test/org/apache/pig/test/TestGrunt.java
URL: 
http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestGrunt.java?rev=1733091&r1=1733090&r2=1733091&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestGrunt.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestGrunt.java Tue Mar  1 15:51:52 2016
@@ -1427,6 +1427,24 @@ public class TestGrunt {
     }
 
     @Test
+    public void testScriptWithSingleQuoteInsideCommentInGenerate() throws 
Throwable {
+        //the query has not store or dump, but in when -check is used
+        // all statements should be validated
+        String query = "a = load 'foo.pig' as (s1:chararray, s2:chararray);\n" 
+
+        "b = foreach a generate s1,\n" +
+        "--comment should be ignored even it has single quote ' in the line 
\n"  +
+        " s2;\n";
+        ArrayList<String> msgs = new ArrayList<String>();                //
+        validate(query, true, msgs.toArray(new String[0]));
+        query = "a = load 'foo.pig' as (s1:chararray, s2:chararray);\n" +
+        "b = foreach a generate s1,\n" +
+        "/* comment should be ignored even it has single quote ' in the line 
\n"  +
+        "*/ \n" +
+        " s2;\n";
+        validate(query, true, msgs.toArray(new String[0]));
+    }
+
+    @Test
     public void testDebugOn() throws Throwable {
 
         String strCmd = "set debug on\n";


Reply via email to