You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by ga...@apache.org on 2011/09/14 02:50:33 UTC

svn commit: r1170405 - in /pig/trunk: CHANGES.txt src/org/apache/pig/scripting/Pig.java test/e2e/pig/tests/turing_jython.conf test/org/apache/pig/test/TestScriptLanguage.java

Author: gates
Date: Wed Sep 14 00:50:32 2011
New Revision: 1170405

URL: http://svn.apache.org/viewvc?rev=1170405&view=rev
Log:
PIG-2273: Pig.compileFromFile in embedded python fails when pig script starts with a comment

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/scripting/Pig.java
    pig/trunk/test/e2e/pig/tests/turing_jython.conf
    pig/trunk/test/org/apache/pig/test/TestScriptLanguage.java

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1170405&r1=1170404&r2=1170405&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Wed Sep 14 00:50:32 2011
@@ -132,6 +132,8 @@ PIG-2011: Speed up TestTypedMap.java (dv
 
 BUG FIXES
 
+PIG-2273: Pig.compileFromFile in embedded python fails when pig script starts with a comment (ddaniels888 via gates)
+
 PIG-2278: Wrong version numbers for libraries in eclipse template classpath (azaroth)
 
 PIG-2152: Null pointer exception while reporting progress (thejas)

Modified: pig/trunk/src/org/apache/pig/scripting/Pig.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/scripting/Pig.java?rev=1170405&r1=1170404&r2=1170405&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/scripting/Pig.java (original)
+++ pig/trunk/src/org/apache/pig/scripting/Pig.java Wed Sep 14 00:50:32 2011
@@ -329,6 +329,7 @@ public class Pig {
         String line = rd.readLine();
         while (line != null) {
             sb.append(line);
+            sb.append("\n");
             line = rd.readLine();
         }
         rd.close();

Modified: pig/trunk/test/e2e/pig/tests/turing_jython.conf
URL: http://svn.apache.org/viewvc/pig/trunk/test/e2e/pig/tests/turing_jython.conf?rev=1170405&r1=1170404&r2=1170405&view=diff
==============================================================================
--- pig/trunk/test/e2e/pig/tests/turing_jython.conf (original)
+++ pig/trunk/test/e2e/pig/tests/turing_jython.conf Wed Sep 14 00:50:32 2011
@@ -366,7 +366,41 @@ result = P.bind().run()
 \,
              'verify_pig_script' => q\A = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
                                       store A into ':OUTPATH:';\,
- 	    }
+ 	    },
+        {
+#  8.6 	compile pig script file with no input and no output parameters
+#12.2 	import python modules 
+#
+		'num' => 10
+		,'pig' => q\#!/usr/bin/python
+from org.apache.pig.scripting import Pig
+
+#create pig script
+pig_script = ":TMP:/script.pig"
+pigfile = open( pig_script, 'w+')
+pigfile.write("""
+A = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
+-- a comment
+store A into ':OUTPATH:';
+""")
+pigfile.close()
+
+#execute pig script
+
+result = Pig.compileFromFile( pig_script ).bind().runSingle()
+
+if result.isSuccessful():
+    print "Pig job PASSED"
+else:
+    raise "Pig job FAILED"    
+\,
+
+             'verify_pig_script' => q\A = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
+                                      store A into ':OUTPATH:';
+\
+                        ,'floatpostprocess' => 1
+                        ,'delimiter' => '	'
+		}
       ] 
 	},{
 	'name' => 'Jython_Diagnostics'

Modified: pig/trunk/test/org/apache/pig/test/TestScriptLanguage.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestScriptLanguage.java?rev=1170405&r1=1170404&r2=1170405&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestScriptLanguage.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestScriptLanguage.java Wed Sep 14 00:50:32 2011
@@ -132,6 +132,7 @@ public class TestScriptLanguage {
         };
         
         String[] pigLatin = {
+                "-- ensure comment parsed correctly",
                 "a = load '$input';",
                 "store a into '$output';"
         };