mirror of https://github.com/apache/druid.git
do not ignore ms in ruby time (#6217)
This commit is contained in:
parent
6e73ad6231
commit
ddb26f2696
|
@ -79,7 +79,6 @@ public class TimestampParser
|
|||
return numericFun.apply(Long.parseLong(ParserUtils.stripQuotes(input)));
|
||||
};
|
||||
} else if ("ruby".equalsIgnoreCase(format)) {
|
||||
// Numeric parser ignores millis for ruby.
|
||||
final Function<Number, DateTime> numericFun = createNumericTimestampParser(format);
|
||||
return input -> {
|
||||
Preconditions.checkArgument(!Strings.isNullOrEmpty(input), "null timestamp");
|
||||
|
@ -103,11 +102,12 @@ public class TimestampParser
|
|||
final String format
|
||||
)
|
||||
{
|
||||
// Ignore millis for ruby
|
||||
if ("posix".equalsIgnoreCase(format) || "ruby".equalsIgnoreCase(format)) {
|
||||
if ("posix".equalsIgnoreCase(format)) {
|
||||
return input -> DateTimes.utc(TimeUnit.SECONDS.toMillis(input.longValue()));
|
||||
} else if ("nano".equalsIgnoreCase(format)) {
|
||||
return input -> DateTimes.utc(TimeUnit.NANOSECONDS.toMillis(input.longValue()));
|
||||
} else if ("ruby".equalsIgnoreCase(format)) {
|
||||
return input -> DateTimes.utc(Double.valueOf(input.doubleValue() * 1000).longValue());
|
||||
} else {
|
||||
return input -> DateTimes.utc(input.longValue());
|
||||
}
|
||||
|
|
|
@ -97,8 +97,8 @@ public class TimestampParserTest
|
|||
public void testRuby()
|
||||
{
|
||||
final Function<Object, DateTime> parser = TimestampParser.createObjectTimestampParser("ruby");
|
||||
Assert.assertEquals(DateTimes.of("2013-01-16T15:41:47+01:00"), parser.apply("1358347307.435447"));
|
||||
Assert.assertEquals(DateTimes.of("2013-01-16T15:41:47+01:00"), parser.apply(1358347307.435447D));
|
||||
Assert.assertEquals(DateTimes.of("2013-01-16T14:41:47.435Z"), parser.apply("1358347307.435447"));
|
||||
Assert.assertEquals(DateTimes.of("2013-01-16T14:41:47.435Z"), parser.apply(1358347307.435447D));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue