Add TimestampSpec format for microsecond (#6395)

This commit is contained in:
QiuMM 2018-09-28 00:38:44 +08:00 committed by Fangjin Yang
parent aef022de98
commit 47a6cca013
2 changed files with 6 additions and 3 deletions

View File

@ -187,7 +187,7 @@ handle all formatting decisions on their own, without using the ParseSpec.
| Field | Type | Description | Required |
|-------|------|-------------|----------|
| column | String | The column of the timestamp. | yes |
| format | String | iso, millis, posix, auto or any [Joda time](http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html) format. | no (default == 'auto' |
| format | String | iso, posix, millis, micro, nano, auto or any [Joda time](http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html) format. | no (default == 'auto' |
### DimensionsSpec

View File

@ -71,8 +71,9 @@ public class TimestampParser
return DateTimes.of(ParserUtils.stripQuotes(input));
};
} else if ("posix".equalsIgnoreCase(format)
|| "millis".equalsIgnoreCase(format)
|| "nano".equalsIgnoreCase(format)) {
|| "millis".equalsIgnoreCase(format)
|| "micro".equalsIgnoreCase(format)
|| "nano".equalsIgnoreCase(format)) {
final Function<Number, DateTime> numericFun = createNumericTimestampParser(format);
return input -> {
Preconditions.checkArgument(!Strings.isNullOrEmpty(input), "null timestamp");
@ -104,6 +105,8 @@ public class TimestampParser
{
if ("posix".equalsIgnoreCase(format)) {
return input -> DateTimes.utc(TimeUnit.SECONDS.toMillis(input.longValue()));
} else if ("micro".equalsIgnoreCase(format)) {
return input -> DateTimes.utc(TimeUnit.MICROSECONDS.toMillis(input.longValue()));
} else if ("nano".equalsIgnoreCase(format)) {
return input -> DateTimes.utc(TimeUnit.NANOSECONDS.toMillis(input.longValue()));
} else if ("ruby".equalsIgnoreCase(format)) {