[ 
https://issues.apache.org/jira/browse/KYLIN-3258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16608625#comment-16608625
 ] 

ASF GitHub Bot commented on KYLIN-3258:
---------------------------------------

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:
us...@infra.apache.org


> No check for duplicate cube name when creating a hybrid cube
> ------------------------------------------------------------
>
>                 Key: KYLIN-3258
>                 URL: https://issues.apache.org/jira/browse/KYLIN-3258
>             Project: Kylin
>          Issue Type: Bug
>          Components: Metadata
>    Affects Versions: v2.2.0
>         Environment: HDP 2.5.6, Kylin 2.2
>            Reporter: Vsevolod Ostapenko
>            Assignee: Shaofeng SHI
>            Priority: Minor
>             Fix For: v2.5.0
>
>
> When loading hybrid cube definitions via REST API, there is no check for 
> duplicate cube names is the list. If due to a user error or incorrectly 
> generated list of cubes by an external application/script the same cube name 
> is listed more than once, new or updated hybrid cube will contain the same 
> cube listed multiple times.
> It does not seem to cause any immediate issues with querying, but it's just 
> not right. REST API should throw and exception, when the same cube name is 
> listed multiple times.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to