pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject svn commit: r1221450 - in /pig/trunk: CHANGES.txt src/org/apache/pig/PigServer.java src/org/apache/pig/tools/grunt/Grunt.java test/org/apache/pig/test/TestScriptLanguage.java
Date Tue, 20 Dec 2011 19:26:20 GMT
Author: daijy
Date: Tue Dec 20 19:26:20 2011
New Revision: 1221450

URL: http://svn.apache.org/viewvc?rev=1221450&view=rev
Log:
PIG-2291: PigStats.isSuccessful returns false if embedded pig script has dump

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/PigServer.java
    pig/trunk/src/org/apache/pig/tools/grunt/Grunt.java
    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=1221450&r1=1221449&r2=1221450&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Tue Dec 20 19:26:20 2011
@@ -336,6 +336,8 @@ Release 0.9.2 - Unreleased
 
 BUG FIXES
 
+PIG-2291: PigStats.isSuccessful returns false if embedded pig script has dump (xutingz via
daijy)
+
 PIG-2415: A fix for 0.23 local mode: put "yarn-default.xml" into the configuration (daijy)
 
 PIG-2402: inIllustrator condition in PigMapReduce is wrong for hadoop 23 (daijy)

Modified: pig/trunk/src/org/apache/pig/PigServer.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/PigServer.java?rev=1221450&r1=1221449&r2=1221450&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/PigServer.java (original)
+++ pig/trunk/src/org/apache/pig/PigServer.java Tue Dec 20 19:26:20 2011
@@ -1240,7 +1240,7 @@ public class PigServer {
         currDAG.compile();
 
         if( currDAG.lp.size() == 0 ) {
-            return PigStatsUtil.getEmptyPigStats();
+           return PigStats.get(); 
         }
         
         PigStats stats = executeCompiledLogicalPlan();

Modified: pig/trunk/src/org/apache/pig/tools/grunt/Grunt.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/tools/grunt/Grunt.java?rev=1221450&r1=1221449&r2=1221450&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/tools/grunt/Grunt.java (original)
+++ pig/trunk/src/org/apache/pig/tools/grunt/Grunt.java Tue Dec 20 19:26:20 2011
@@ -29,6 +29,7 @@ import org.apache.pig.impl.PigContext;
 import org.apache.pig.tools.grunt.GruntParser;
 import org.apache.pig.tools.grunt.PigCompletor;
 import org.apache.pig.tools.grunt.PigCompletorAliases;
+import org.apache.pig.tools.pigstats.PigStatsUtil;
 import org.apache.pig.backend.executionengine.ExecException;
 import org.apache.pig.impl.util.LogUtils;
 
@@ -63,6 +64,7 @@ public class Grunt 
         boolean verbose = "true".equalsIgnoreCase(pig.getPigContext().getProperties().getProperty("verbose"));
         while(true) {
             try {
+                PigStatsUtil.getEmptyPigStats();
                 parser.setInteractive(true);
                 parser.parseStopOnError();
                 break;                            
@@ -77,6 +79,7 @@ public class Grunt 
     public int[] exec() throws Throwable {
         boolean verbose = "true".equalsIgnoreCase(pig.getPigContext().getProperties().getProperty("verbose"));
         try {
+            PigStatsUtil.getEmptyPigStats();
             parser.setInteractive(false);
             return parser.parseStopOnError();
         } catch (Throwable t) {

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=1221450&r1=1221449&r2=1221450&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestScriptLanguage.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestScriptLanguage.java Tue Dec 20 19:26:20 2011
@@ -583,5 +583,76 @@ public class TestScriptLanguage {
         s = (String)fixNonEscapedDollarSign.invoke(null, "$$abc");
         assertEquals("\\\\$\\\\$abc", s);
     }
-       
+    
+    // See PIG-2291
+    @Test
+    public void testDumpInScript() throws Exception{
+    	
+    	  String[] script = {
+                  "#!/usr/bin/python",
+                  "from org.apache.pig.scripting import *",
+                  "Pig.fs(\"rmr simple_out\")",
+                  "input = 'testDumpInScript_table'",
+                  "output = 'simple_out'",
+                  "P = Pig.compileFromFile(\"\"\"testScript.pig\"\"\")",
+                  "Q = P.bind({'input':input, 'output':output})",
+                  "stats = Q.runSingle()",
+                  "if stats.isSuccessful():",
+                  "\tprint 'success!'",
+                  "else:",
+                  "\tprint 'failed'"
+          };
+        String[] input = {
+                "1\t3",
+                "2\t4",
+                "3\t5"
+        };
+        
+        String[] pigLatin = {
+                "a = load '$input' as (a0:int,a1:int);",
+                "store a into '$output';",
+                "dump a"
+        };
+        
+        Util.createInputFile(cluster, "testDumpInScript_table", input);
+        Util.createLocalInputFile( "testScript.py", script);
+        Util.createLocalInputFile( "testScript.pig", pigLatin);
+        
+        ScriptEngine scriptEngine = ScriptEngine.getInstance("jython");
+        Map<String, List<PigStats>> statsMap = scriptEngine.run(pigServer.getPigContext(),
"testScript.py");
+        Iterator<List<PigStats>> it = statsMap.values().iterator();  
+        PigStats stats = it.next().get(0);
+        assertTrue(stats.isSuccessful());
+    }
+
+	// See PIG-2291
+	@Test
+	public void testIllustrateInScript() throws Exception {
+
+		String[] script = { "#!/usr/bin/python",
+				"from org.apache.pig.scripting import *",
+				"Pig.fs(\"rmr simple_out\")",
+				"input = 'testIllustrateInScript_table'",
+				"output = 'simple_out'",
+				"P = Pig.compileFromFile(\"\"\"testScript.pig\"\"\")",
+				"Q = P.bind({'input':input, 'output':output})",
+				"stats = Q.runSingle()", "if stats.isSuccessful():",
+				"\tprint 'success!'", "else:", "\tprint 'failed'" };
+		String[] input = { "1\t3", "2\t4", "3\t5" };
+
+		String[] pigLatin = { "a = load '$input' as (a0:int,a1:int);",
+				"store a into '$output';", "illustrate a" };
+
+		Util.createInputFile(cluster, "testIllustrateInScript_table", input);
+		Util.createLocalInputFile("testScript.py", script);
+		Util.createLocalInputFile("testScript.pig", pigLatin);
+
+		ScriptEngine scriptEngine = ScriptEngine.getInstance("jython");
+		Map<String, List<PigStats>> statsMap = scriptEngine.run(
+				pigServer.getPigContext(), "testScript.py");
+		Iterator<List<PigStats>> it = statsMap.values().iterator();
+		PigStats stats = it.next().get(0);
+		assertTrue(stats.isSuccessful());
+	}
+
 }



Mime
View raw message