Author: sms
Date: Mon Jun 8 21:27:19 2009
New Revision: 782790
URL: http://svn.apache.org/viewvc?rev=782790&view=rev
Log:
PIG-839: incorrect return codes on failure when using -f or -e flags (hagletin
via sms)
Modified:
hadoop/pig/trunk/CHANGES.txt
hadoop/pig/trunk/src/org/apache/pig/Main.java
Modified: hadoop/pig/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/pig/trunk/CHANGES.txt?rev=782790&r1=782789&r2=782790&view=diff
==============================================================================
--- hadoop/pig/trunk/CHANGES.txt (original)
+++ hadoop/pig/trunk/CHANGES.txt Mon Jun 8 21:27:19 2009
@@ -75,6 +75,9 @@
BUG FIXES
+PIG-839: incorrect return codes on failure when using -f or -e flags (hagletin
+via sms)
+
PIG-796: support conversion from numeric types to chararray (Ashutosh Chauhan
via pradeepkth)
Modified: hadoop/pig/trunk/src/org/apache/pig/Main.java
URL:
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/Main.java?rev=782790&r1=782789&r2=782790&view=diff
==============================================================================
--- hadoop/pig/trunk/src/org/apache/pig/Main.java (original)
+++ hadoop/pig/trunk/src/org/apache/pig/Main.java Mon Jun 8 21:27:19 2009
@@ -278,14 +278,14 @@
BufferedReader in;
String substFile = null;
switch (mode) {
- case FILE:
+ case FILE: {
// Run, using the provided file as a pig file
in = new BufferedReader(new FileReader(file));
// run parameter substitution preprocessor first
substFile = file + ".substituted";
pin = runParamPreprocessor(in, params, paramFiles, substFile,
debug || dryrun);
- if (dryrun){
+ if (dryrun) {
log.info("Dry run completed. Substituted pig script is at " +
substFile);
return;
}
@@ -298,14 +298,16 @@
"PigLatin:" +new
File(file).getName()
);
- if (!debug)
+ if (!debug) {
new File(substFile).deleteOnExit();
+ }
grunt = new Grunt(pin, pigContext);
gruntCalled = true;
- grunt.exec();
- rc = 0;
+ int results[] = grunt.exec();
+ rc = getReturnCodeForStats(results);
return;
+ }
case STRING: {
// Gather up all the remaining arguments into a string and pass
them into
@@ -319,8 +321,8 @@
in = new BufferedReader(new StringReader(sb.toString()));
grunt = new Grunt(in, pigContext);
gruntCalled = true;
- grunt.exec();
- rc = 0;
+ int results[] = grunt.exec();
+ rc = getReturnCodeForStats(results);
return;
}
@@ -380,20 +382,7 @@
grunt = new Grunt(pin, pigContext);
gruntCalled = true;
int[] results = grunt.exec();
- if (results[1] == 0) {
- // no failed jobs
- rc = 0;
- }
- else {
- if (results[0] == 0) {
- // no succeeded jobs
- rc = 2;
- }
- else {
- // some jobs have failed
- rc = 3;
- }
- }
+ rc = getReturnCodeForStats(results);
return;
}
@@ -427,6 +416,23 @@
}
}
+private static int getReturnCodeForStats(int[] stats) {
+ if (stats[1] == 0) {
+ // no failed jobs
+ return 0;
+ }
+ else {
+ if (stats[0] == 0) {
+ // no succeeded jobs
+ return 2;
+ }
+ else {
+ // some jobs have failed
+ return 3;
+ }
+ }
+}
+
//TODO jz: log4j.properties should be used instead
private static void configureLog4J(Properties properties) {
// TODO Add a file appender for the logs