From 454587857c89800409744b639632da1fc7eb4a30 Mon Sep 17 00:00:00 2001 From: Jonathan Wei Date: Thu, 11 Aug 2016 18:00:11 -0700 Subject: [PATCH] Make StringComparator deserialization case-insensitive (#3356) --- .../main/java/io/druid/query/ordering/StringComparator.java | 2 +- .../java/io/druid/query/ordering/StringComparatorsTest.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/processing/src/main/java/io/druid/query/ordering/StringComparator.java b/processing/src/main/java/io/druid/query/ordering/StringComparator.java index f61cab877a2..d88c78ecc8a 100644 --- a/processing/src/main/java/io/druid/query/ordering/StringComparator.java +++ b/processing/src/main/java/io/druid/query/ordering/StringComparator.java @@ -29,7 +29,7 @@ public abstract class StringComparator implements Comparator @JsonCreator public static StringComparator fromString(String type) { - switch (type) { + switch (type.toLowerCase()) { case StringComparators.LEXICOGRAPHIC_NAME: return StringComparators.LEXICOGRAPHIC; case StringComparators.ALPHANUMERIC_NAME: diff --git a/processing/src/test/java/io/druid/query/ordering/StringComparatorsTest.java b/processing/src/test/java/io/druid/query/ordering/StringComparatorsTest.java index 1273921b29b..b40f721f451 100644 --- a/processing/src/test/java/io/druid/query/ordering/StringComparatorsTest.java +++ b/processing/src/test/java/io/druid/query/ordering/StringComparatorsTest.java @@ -207,5 +207,9 @@ public class StringComparatorsTest String makeFromJsonSpec = "\"numeric\""; Assert.assertEquals(StringComparators.NUMERIC , jsonMapper.readValue(makeFromJsonSpec, StringComparator.class)); + + makeFromJsonSpec = "\"NuMeRiC\""; + Assert.assertEquals(StringComparators.NUMERIC + , jsonMapper.readValue(makeFromJsonSpec, StringComparator.class)); } }