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/07/27 22:06:01 UTC

[GitHub] jihoonson closed pull request #5699: Convert pair returned by first/last aggregators to number (#5566)

jihoonson closed pull request #5699: Convert pair returned by first/last aggregators to number (#5566)
URL: https://github.com/apache/incubator-druid/pull/5699
 
 
   

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/api/src/main/java/io/druid/data/input/Rows.java b/api/src/main/java/io/druid/data/input/Rows.java
index 0ef09e9fa24..a963c605944 100644
--- a/api/src/main/java/io/druid/data/input/Rows.java
+++ b/api/src/main/java/io/druid/data/input/Rows.java
@@ -23,6 +23,7 @@
 import com.google.common.collect.ImmutableSortedSet;
 import com.google.common.collect.Maps;
 import com.google.common.primitives.Longs;
+import io.druid.java.util.common.Pair;
 import io.druid.java.util.common.StringUtils;
 import io.druid.java.util.common.parsers.ParseException;
 
@@ -116,6 +117,8 @@ public static Number objectToNumber(final String name, final Object inputValue)
       catch (Exception e) {
         throw new ParseException(e, "Unable to parse value[%s] for field[%s]", inputValue, name);
       }
+    } else if (inputValue instanceof Pair) {
+      return objectToNumber(name, ((Pair) inputValue).rhs);
     } else {
       throw new ParseException("Unknown type[%s] for field", inputValue.getClass(), inputValue);
     }
diff --git a/api/src/test/java/io/druid/data/input/MapBasedRowTest.java b/api/src/test/java/io/druid/data/input/MapBasedRowTest.java
index b6b4d5a9840..aacf66c1a83 100644
--- a/api/src/test/java/io/druid/data/input/MapBasedRowTest.java
+++ b/api/src/test/java/io/druid/data/input/MapBasedRowTest.java
@@ -21,6 +21,7 @@
 
 import com.google.common.collect.ImmutableMap;
 import io.druid.java.util.common.DateTimes;
+import io.druid.java.util.common.Pair;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -39,6 +40,7 @@ public void testGetLongMetricFromString()
           .put("k4", "9223372036854775806")
           .put("k5", "-9223372036854775807")
           .put("k6", "+9223372036854775802")
+          .put("k7", new Pair<>(1234L, "1.24"))
           .build()
     );
     
@@ -49,5 +51,6 @@ public void testGetLongMetricFromString()
     Assert.assertEquals(9223372036854775806L, row.getMetric("k4"));
     Assert.assertEquals(-9223372036854775807L, row.getMetric("k5"));
     Assert.assertEquals(9223372036854775802L, row.getMetric("k6"));
+    Assert.assertEquals(1.24, row.getMetric("k7"));
   }
 }


 

----------------------------------------------------------------
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