Skip to content

Instantly share code, notes, and snippets.

@rjurney
Created May 17, 2012 05:55
Show Gist options
  • Save rjurney/2716816 to your computer and use it in GitHub Desktop.
Save rjurney/2716816 to your computer and use it in GitHub Desktop.
Hacking Datetimes into mongo-hadoop
// Note: Pig does not have a DateTime type yet, so this is hackery.
// See https://issues.apache.org/jira/browse/PIG-1314
case DataType.CHARARRAY:
// If it starts like an ISODate...
if((String)d.startsWith("ISODate(")) {
// and it ends like an ISODate...
if((String)d.endsWith(")")) {
// lets treat it like an ISODate.
try {
builder.add( field.getName(), new Date((String)d));
}
catch (Exception e) {
e.printStackTrace();
}
}
}
builder.add( field.getName(), (String)d );
return;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment