Skip to content

Commit

Permalink
Scala Common Enrich: ensured that all timestamp fields are nonnegative (
Browse files Browse the repository at this point in the history
closes #1938)
  • Loading branch information
fblundun authored and alexanderdean committed Jan 14, 2016
1 parent 30bb789 commit 71be005
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@ object EventEnrichments {
val extractTimestamp: (String, String) => ValidatedString = (field, tstamp) =>
try {
val dt = new DateTime(tstamp.toLong)
toTimestamp(dt).success
val timestampString = toTimestamp(dt)
if (timestampString.startsWith("-")) {
s"Field [$field]: [$tstamp] is formatted as [$timestampString] which isn't Redshift-compatible".fail
} else {
timestampString.success
}
} catch {
case nfe: NumberFormatException =>
"Field [%s]: [%s] is not in the expected format (ms since epoch)".format(field, tstamp).fail
Expand Down

0 comments on commit 71be005

Please sign in to comment.