kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lid...@apache.org
Subject [5/9] kylin git commit: KYLIN-2316 Global dict couldn't be used for dimension column
Date Fri, 10 Feb 2017 04:02:41 GMT
KYLIN-2316 Global dict couldn't be used for dimension column


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/3ee49467
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/3ee49467
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/3ee49467

Branch: refs/heads/master-hbase0.98
Commit: 3ee49467ce686d11afcecbc636bb5213b0927427
Parents: 7fa25e0
Author: kangkaisen <kangkaisen@163.com>
Authored: Thu Feb 9 19:54:26 2017 +0800
Committer: kangkaisen <kangkaisen@163.com>
Committed: Thu Feb 9 20:28:17 2017 +0800

----------------------------------------------------------------------
 .../kylin/cube/model/validation/rule/DictionaryRule.java |  9 +++++++++
 .../cube/model/validation/rule/DictionaryRuleTest.java   | 11 +++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/3ee49467/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/DictionaryRule.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/DictionaryRule.java
b/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/DictionaryRule.java
index 37889c2..8da3ca0 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/DictionaryRule.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/DictionaryRule.java
@@ -29,6 +29,7 @@ import org.apache.kylin.cube.model.DictionaryDesc;
 import org.apache.kylin.cube.model.validation.IValidatorRule;
 import org.apache.kylin.cube.model.validation.ResultLevel;
 import org.apache.kylin.cube.model.validation.ValidateContext;
+import org.apache.kylin.dict.GlobalDictionaryBuilder;
 import org.apache.kylin.metadata.model.TblColRef;
 
 /**
@@ -45,10 +46,13 @@ public class DictionaryRule implements IValidatorRule<CubeDesc>
{
     static final String ERROR_REUSE_BUILDER_BOTH_SET = "REUSE and BUILDER both set on dictionary
for column: ";
     static final String ERROR_REUSE_BUILDER_BOTH_EMPTY = "REUSE and BUILDER both empty on
dictionary for column: ";
     static final String ERROR_TRANSITIVE_REUSE = "Transitive REUSE is not allowed for dictionary:
";
+    static final String ERROR_GLOBAL_DICTIONNARY_ONLY_MEASURE = "Global dictionary couldn't
be used for dimension column: ";
 
     @Override
     public void validate(CubeDesc cubeDesc, ValidateContext context) {
         List<DictionaryDesc> dictDescs = cubeDesc.getDictionaries();
+        Set<TblColRef> dimensionColumns = cubeDesc.listDimensionColumnsIncludingDerived();
+
         if (dictDescs == null || dictDescs.isEmpty()) {
             return;
         }
@@ -78,6 +82,11 @@ public class DictionaryRule implements IValidatorRule<CubeDesc> {
                 return;
             }
 
+            if (StringUtils.isNotEmpty(builderClass) && builderClass.equalsIgnoreCase(GlobalDictionaryBuilder.class.getName())
&& dimensionColumns.contains(dictCol)) {
+                context.addResult(ResultLevel.ERROR, ERROR_GLOBAL_DICTIONNARY_ONLY_MEASURE
+ dictCol);
+                return;
+            }
+
             if (reuseCol != null) {
                 reuseDictionaries.add(dictDesc);
             } else {

http://git-wip-us.apache.org/repos/asf/kylin/blob/3ee49467/core-cube/src/test/java/org/apache/kylin/cube/model/validation/rule/DictionaryRuleTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/cube/model/validation/rule/DictionaryRuleTest.java
b/core-cube/src/test/java/org/apache/kylin/cube/model/validation/rule/DictionaryRuleTest.java
index 452768f..fcb723e 100644
--- a/core-cube/src/test/java/org/apache/kylin/cube/model/validation/rule/DictionaryRuleTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/cube/model/validation/rule/DictionaryRuleTest.java
@@ -19,6 +19,7 @@
 package org.apache.kylin.cube.model.validation.rule;
 
 import static org.apache.kylin.cube.model.validation.rule.DictionaryRule.ERROR_DUPLICATE_DICTIONARY_COLUMN;
+import static org.apache.kylin.cube.model.validation.rule.DictionaryRule.ERROR_GLOBAL_DICTIONNARY_ONLY_MEASURE;
 import static org.apache.kylin.cube.model.validation.rule.DictionaryRule.ERROR_REUSE_BUILDER_BOTH_EMPTY;
 import static org.apache.kylin.cube.model.validation.rule.DictionaryRule.ERROR_REUSE_BUILDER_BOTH_SET;
 import static org.apache.kylin.cube.model.validation.rule.DictionaryRule.ERROR_TRANSITIVE_REUSE;
@@ -91,10 +92,16 @@ public class DictionaryRuleTest extends LocalFileMetadataTestCase {
                 DictionaryDesc.create("lstg_site_id", "SELLER_ID", null),
                 DictionaryDesc.create("price", "lstg_site_id", null));
     }
-    
+
+    @Test
+    public void testBadDesc5() throws IOException {
+        testDictionaryDesc(ERROR_GLOBAL_DICTIONNARY_ONLY_MEASURE,
+                DictionaryDesc.create("CATEG_LVL2_NAME", null, GlobalDictionaryBuilder.class.getName()));
+    }
+
     @Test
     public void testGoodDesc2() throws IOException {
-        testDictionaryDesc(null, DictionaryDesc.create("lstg_site_id", null, GlobalDictionaryBuilder.class.getName()));
+        testDictionaryDesc(null, DictionaryDesc.create("SELLER_ID", null, GlobalDictionaryBuilder.class.getName()));
     }
 
     private void testDictionaryDesc(String expectMessage, DictionaryDesc... descs) throws
IOException {


Mime
View raw message