You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by da...@apache.org on 2012/03/13 22:56:53 UTC

svn commit: r1300373 - in /pig/trunk: CHANGES.txt src/org/apache/pig/tools/grunt/GruntParser.java src/org/apache/pig/tools/pigstats/SimplePigStats.java test/e2e/pig/tests/turing_jython.conf

Author: daijy
Date: Tue Mar 13 21:56:53 2012
New Revision: 1300373

URL: http://svn.apache.org/viewvc?rev=1300373&view=rev
Log:
PIG-2543: PigStats.isSuccessful returns false if embedded pig script has sh commands

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/tools/grunt/GruntParser.java
    pig/trunk/src/org/apache/pig/tools/pigstats/SimplePigStats.java
    pig/trunk/test/e2e/pig/tests/turing_jython.conf

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1300373&r1=1300372&r2=1300373&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Tue Mar 13 21:56:53 2012
@@ -269,6 +269,8 @@ PIG-2228: support partial aggregation in
 
 BUG FIXES
 
+PIG-2543: PigStats.isSuccessful returns false if embedded pig script has sh commands (daijy)
+
 PIG-2509: Util.getSchemaFromString fails with java.lang.NullPointerException when a tuple in a bag has no name (as when used in MongoStorage UDF) (jcoveney via daijy)
 
 PIG-2559: Embedded pig in python; invoking sys.exit(0) causes script failure (vivekp via daijy)

Modified: pig/trunk/src/org/apache/pig/tools/grunt/GruntParser.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/tools/grunt/GruntParser.java?rev=1300373&r1=1300372&r2=1300373&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/tools/grunt/GruntParser.java (original)
+++ pig/trunk/src/org/apache/pig/tools/grunt/GruntParser.java Tue Mar 13 21:56:53 2012
@@ -1009,11 +1009,14 @@ public class GruntParser extends PigScri
                 int ret = executor.waitFor();
                 outPrinter.join();
                 errPrinter.join();
-                if (ret != 0) {
-                    log.warn("Command failed with exit code = " + ret);
+                if (ret != 0 && !mInteractive) {
+                    String s = LoadFunc.join(
+                            (AbstractList<String>) Arrays.asList(cmdTokens), " ");
+                    throw new IOException("sh command '" + s
+                            + "' failed. Please check output logs for details");
                 }
             } catch (Exception e) {
-                log.warn("Exception raised from Shell command " + e.getLocalizedMessage());
+                throw new IOException(e);
             }
         } else {
             log.warn("'sh' statement is ignored while processing 'explain -script' or '-check'");

Modified: pig/trunk/src/org/apache/pig/tools/pigstats/SimplePigStats.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/tools/pigstats/SimplePigStats.java?rev=1300373&r1=1300372&r2=1300373&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/tools/pigstats/SimplePigStats.java (original)
+++ pig/trunk/src/org/apache/pig/tools/pigstats/SimplePigStats.java Tue Mar 13 21:56:53 2012
@@ -165,7 +165,8 @@ final class SimplePigStats extends PigSt
     
     @Override
     public boolean isSuccessful() {
-        return (returnCode == ReturnCode.SUCCESS);
+        return (getNumberJobs()==0 && returnCode==ReturnCode.UNKNOWN
+                || returnCode == ReturnCode.SUCCESS);
     }
  
     @Override

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=1300373&r1=1300372&r2=1300373&view=diff
==============================================================================
--- pig/trunk/test/e2e/pig/tests/turing_jython.conf (original)
+++ pig/trunk/test/e2e/pig/tests/turing_jython.conf Tue Mar 13 21:56:53 2012
@@ -1017,6 +1017,39 @@ else:
     raise "SQL command FAILED"    
 \
                        ,'rc' => 0
+                    },
+                    {
+                        # sql command
+		                'num' => 2
+		                ,'pig' => q\#!/usr/bin/python
+from org.apache.pig.scripting import Pig
+
+Q = Pig.compile("sh echo mymessage")
+result = Q.bind().runSingle()
+
+if result.isSuccessful() :
+    print 'Pig job succeeded'
+else :
+    raise 'Cant run sh command'
+\
+                       ,'rc' => 0
+                       ,'expected_out_regex' => "mymessage\nPig job succeeded"
+                    },
+                    {
+                        # sql command
+		                'num' => 3
+		                ,'pig' => q\#!/usr/bin/python
+from org.apache.pig.scripting import Pig
+
+Q = Pig.compile("sh cat nonexistfile")
+result = Q.bind().runSingle()
+
+if result.isSuccessful() :
+    print 'Pig job succeeded'
+else :
+    raise 'Cant run sh command'
+\
+                       ,'rc' => 6
                     }
                 ]
             }