You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2018/08/23 21:09:33 UTC

[GitHub] gianm closed pull request #6217: do not ignore ms in ruby time

gianm closed pull request #6217: do not ignore ms in ruby time
URL: https://github.com/apache/incubator-druid/pull/6217
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/java-util/src/main/java/io/druid/java/util/common/parsers/TimestampParser.java b/java-util/src/main/java/io/druid/java/util/common/parsers/TimestampParser.java
index 7019a550db0..14de994aeda 100644
--- a/java-util/src/main/java/io/druid/java/util/common/parsers/TimestampParser.java
+++ b/java-util/src/main/java/io/druid/java/util/common/parsers/TimestampParser.java
@@ -79,7 +79,6 @@
         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 @@
       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());
     }
diff --git a/java-util/src/test/java/io/druid/java/util/common/parsers/TimestampParserTest.java b/java-util/src/test/java/io/druid/java/util/common/parsers/TimestampParserTest.java
index c8738f40141..ef6960d6729 100644
--- a/java-util/src/test/java/io/druid/java/util/common/parsers/TimestampParserTest.java
+++ b/java-util/src/test/java/io/druid/java/util/common/parsers/TimestampParserTest.java
@@ -97,8 +97,8 @@ public void testAutoInvalid()
   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


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org