You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by ji...@apache.org on 2019/05/21 00:49:21 UTC
[incubator-druid] branch master updated: Fix case insensitive of
ParserUtils.findDuplicates (#7692)
This is an automated email from the ASF dual-hosted git repository.
jihoonson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-druid.git
The following commit(s) were added to refs/heads/master by this push:
new d69aa6f Fix case insensitive of ParserUtils.findDuplicates (#7692)
d69aa6f is described below
commit d69aa6f7f660e3839dc9f829753bb31c0046a9ea
Author: Jihoon Son <ji...@apache.org>
AuthorDate: Mon May 20 17:49:15 2019 -0700
Fix case insensitive of ParserUtils.findDuplicates (#7692)
* Fix case insensitive ParserUtils.findDuplicates
* unused import
---
.../druid/data/input/impl/DimensionsSpec.java | 4 +-
.../java/util/common/parsers/ParserUtils.java | 12 +++---
.../java/util/common/parsers/ParserUtilsTest.java | 45 ++++++++++++++++++++++
3 files changed, 52 insertions(+), 9 deletions(-)
diff --git a/core/src/main/java/org/apache/druid/data/input/impl/DimensionsSpec.java b/core/src/main/java/org/apache/druid/data/input/impl/DimensionsSpec.java
index ab23b4a..54c90e0 100644
--- a/core/src/main/java/org/apache/druid/data/input/impl/DimensionsSpec.java
+++ b/core/src/main/java/org/apache/druid/data/input/impl/DimensionsSpec.java
@@ -199,9 +199,6 @@ public class DimensionsSpec
"dimensions and dimensions exclusions cannot overlap"
);
- ParserUtils.validateFields(dimNames);
- ParserUtils.validateFields(dimensionExclusions);
-
List<String> spatialDimNames = Lists.transform(
spatialDimensions,
new Function<SpatialDimensionSchema, String>()
@@ -216,6 +213,7 @@ public class DimensionsSpec
// Don't allow duplicates between main list and deprecated spatial list
ParserUtils.validateFields(Iterables.concat(dimNames, spatialDimNames));
+ ParserUtils.validateFields(dimensionExclusions);
}
@Override
diff --git a/core/src/main/java/org/apache/druid/java/util/common/parsers/ParserUtils.java b/core/src/main/java/org/apache/druid/java/util/common/parsers/ParserUtils.java
index bfe732c..57f52c8 100644
--- a/core/src/main/java/org/apache/druid/java/util/common/parsers/ParserUtils.java
+++ b/core/src/main/java/org/apache/druid/java/util/common/parsers/ParserUtils.java
@@ -19,10 +19,10 @@
package org.apache.druid.java.util.common.parsers;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Splitter;
import org.apache.druid.common.config.NullHandling;
-import org.apache.druid.java.util.common.StringUtils;
import org.joda.time.DateTimeZone;
import javax.annotation.Nullable;
@@ -77,17 +77,17 @@ public class ParserUtils
return names;
}
- public static Set<String> findDuplicates(Iterable<String> fieldNames)
+ @VisibleForTesting
+ static Set<String> findDuplicates(Iterable<String> fieldNames)
{
Set<String> duplicates = new HashSet<>();
Set<String> uniqueNames = new HashSet<>();
for (String fieldName : fieldNames) {
- String next = StringUtils.toLowerCase(fieldName);
- if (uniqueNames.contains(next)) {
- duplicates.add(next);
+ if (uniqueNames.contains(fieldName)) {
+ duplicates.add(fieldName);
}
- uniqueNames.add(next);
+ uniqueNames.add(fieldName);
}
return duplicates;
diff --git a/core/src/test/java/org/apache/druid/java/util/common/parsers/ParserUtilsTest.java b/core/src/test/java/org/apache/druid/java/util/common/parsers/ParserUtilsTest.java
new file mode 100644
index 0000000..5645733
--- /dev/null
+++ b/core/src/test/java/org/apache/druid/java/util/common/parsers/ParserUtilsTest.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.java.util.common.parsers;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.List;
+
+public class ParserUtilsTest
+{
+ @Test
+ public void testFindDuplicatesMixedCases()
+ {
+ final List<String> fields = ImmutableList.of("f1", "f2", "F1", "F2", "f3");
+ Assert.assertEquals(Collections.emptySet(), ParserUtils.findDuplicates(fields));
+ }
+
+ @Test
+ public void testFindDuplicates()
+ {
+ final List<String> fields = ImmutableList.of("f1", "f2", "F1", "F2", "f1", "F2");
+ Assert.assertEquals(ImmutableSet.of("f1", "F2"), ParserUtils.findDuplicates(fields));
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org