shaofengshi closed pull request #223: KYLIN-3258 No check for duplicate cube 
name when creating a hybrid cube
URL: https://github.com/apache/kylin/pull/223
 
 
   

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/server-base/src/main/java/org/apache/kylin/rest/job/HybridCubeCLI.java 
b/server-base/src/main/java/org/apache/kylin/rest/job/HybridCubeCLI.java
index 48e7f40973..e332e1d7d7 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/job/HybridCubeCLI.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/job/HybridCubeCLI.java
@@ -20,11 +20,14 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
 
 import org.apache.commons.cli.Option;
 import org.apache.commons.cli.OptionBuilder;
 import org.apache.commons.cli.Options;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.kylin.common.KylinConfig;
 import org.apache.kylin.common.persistence.ResourceStore;
@@ -145,6 +148,17 @@ protected void execute(OptionsHelper optionsHelper) throws 
Exception {
             
realizationEntries.add(RealizationEntry.create(RealizationType.CUBE, 
cube.getName()));
         }
 
+        int realizationEntriesLen = realizationEntries.size();
+        HashSet<RealizationEntry> hashSet = new HashSet<>();
+        for (int i = 0; i < realizationEntriesLen; i++) {
+            hashSet.add(realizationEntries.get(i));
+        }
+        int hashSetLen = hashSet.size();
+        if (realizationEntriesLen != hashSetLen) {
+            Collection<RealizationEntry> duplicateCubes = 
CollectionUtils.subtract(realizationEntries, hashSet);
+            throw new IllegalArgumentException("The Cubes name does duplicate, 
could not create: " + duplicateCubes);
+        }
+
         if ("create".equals(action)) {
             if (hybridInstance != null) {
                 throw new IllegalArgumentException("The Hybrid Cube does 
exist, could not create: " + hybridName);


 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to