Permalink
Browse files

better error checking

  • Loading branch information...
1 parent d5f0328 commit aa66ebe3bf3f966dde96b85e21f3069138eeab5f Bob Briski committed Jul 9, 2012
Showing with 15 additions and 5 deletions.
  1. +15 −5 piggy/src/date_utils/TimeZoneConverter.java
@@ -22,10 +22,20 @@
* be (date, date_format, from_timezone, to_timezone)
*/
public String exec(Tuple input) throws IOException {
- String date = input.get(0).toString();
- String dateFormat = input.get(1).toString();
- String fromTimeZone = input.get(2).toString();
- String toTimeZone = input.get(3).toString();
+ if (input == null || input.size() < 1) {
+ return null;
+ }
+
+ try {
+ String date = input.get(0).toString();
+ String dateFormat = input.get(1).toString();
+ String fromTimeZone = input.get(2).toString();
+ String toTimeZone = input.get(3).toString();
+ }
+ catch (Exception e) {
+ warn("Could not parse input, possible nulls");
+ return null;
+ }
Date d = null;
DateFormat df1 = new SimpleDateFormat(dateFormat);
@@ -36,7 +46,7 @@ public String exec(Tuple input) throws IOException {
} catch (Exception e) {
warn("Could not parse date: " + date + " with format: "
+ dateFormat, PigWarning.UDF_WARNING_1);
- return "";
+ return null;
}
DateFormat df2 = new SimpleDateFormat(dateFormat);

0 comments on commit aa66ebe

Please sign in to comment.