Skip to content

Commit

Permalink
PIG-2543: PigStats.isSuccessful returns false if embedded pig script …
Browse files Browse the repository at this point in the history
…has sh commands

git-svn-id: https://svn.apache.org/repos/asf/pig/trunk@1300373 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Jianyong Dai committed Mar 13, 2012
1 parent 6c21599 commit ab55791
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ PIG-2228: support partial aggregation in map task (thejas)

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)
Expand Down
9 changes: 6 additions & 3 deletions src/org/apache/pig/tools/grunt/GruntParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -1009,11 +1009,14 @@ protected void processShCommand(String[] cmdTokens) throws IOException{
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'");
Expand Down
3 changes: 2 additions & 1 deletion src/org/apache/pig/tools/pigstats/SimplePigStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ public boolean isEmbedded() {

@Override
public boolean isSuccessful() {
return (returnCode == ReturnCode.SUCCESS);
return (getNumberJobs()==0 && returnCode==ReturnCode.UNKNOWN
|| returnCode == ReturnCode.SUCCESS);
}

@Override
Expand Down
33 changes: 33 additions & 0 deletions test/e2e/pig/tests/turing_jython.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}
Expand Down

0 comments on commit ab55791

Please sign in to comment.