kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaofeng...@apache.org
Subject [4/5] kylin git commit: KYLIN-2112 Allow a column be a dimension as well as "group by" column in TopN measure
Date Thu, 20 Oct 2016 07:02:52 GMT
KYLIN-2112 Allow a column be a dimension as well as "group by" column in TopN measure	


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

Branch: refs/heads/yang21
Commit: 0b3b6f415e72d969a9fd15b34a2275eb01d40b70
Parents: 5631749
Author: shaofengshi <shaofengshi@apache.org>
Authored: Thu Oct 20 13:31:39 2016 +0800
Committer: shaofengshi <shaofengshi@apache.org>
Committed: Thu Oct 20 14:37:49 2016 +0800

----------------------------------------------------------------------
 .../model/validation/rule/FunctionRule.java     | 46 +++++++++-----------
 .../kylin/measure/topn/TopNMeasureType.java     |  2 -
 ...test_kylin_cube_with_slr_left_join_desc.json | 24 ++++++++++
 3 files changed, 44 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/0b3b6f41/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/FunctionRule.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/FunctionRule.java
b/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/FunctionRule.java
index 792f18d..bcc9010 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/FunctionRule.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/FunctionRule.java
@@ -62,10 +62,10 @@ public class FunctionRule implements IValidatorRule<CubeDesc> {
     public void validate(CubeDesc cube, ValidateContext context) {
         List<MeasureDesc> measures = cube.getMeasures();
 
-        if (validateMeasureNamesDuplicated(measures, context)) {
-            return;
-        }
-
+        if (validateMeasureNamesDuplicated(measures, context)) {
+            return;
+        }
+
         List<FunctionDesc> countFuncs = new ArrayList<FunctionDesc>();
 
         Iterator<MeasureDesc> it = measures.iterator();
@@ -126,12 +126,6 @@ public class FunctionRule implements IValidatorRule<CubeDesc> {
                     groupByCol = groupByCol.getNextParameter();
                 }
 
-                if (duplicatedCol.size() > 0) {
-                    context.addResult(ResultLevel.ERROR, "Couldn't use " + duplicatedCol.toString()
+ " in Top-N as it is already defined as dimension.");
-                    return;
-
-                }
-
             }
         }
 
@@ -189,20 +183,20 @@ public class FunctionRule implements IValidatorRule<CubeDesc>
{
         }
 
     }
-
-    /**
-     * @param measures
-     */
-    private boolean validateMeasureNamesDuplicated(List<MeasureDesc> measures, ValidateContext
context) {
-        Set<String> nameSet = new HashSet<>();
-        for (MeasureDesc measure: measures){
-            if (nameSet.contains(measure.getName())){
-                context.addResult(ResultLevel.ERROR, "There is duplicated measure's name:
" + measure.getName());
-                return true;
-            } else {
-                nameSet.add(measure.getName());
-            }
-        }
-        return false;
-    }
+
+    /**
+     * @param measures
+     */
+    private boolean validateMeasureNamesDuplicated(List<MeasureDesc> measures, ValidateContext
context) {
+        Set<String> nameSet = new HashSet<>();
+        for (MeasureDesc measure: measures){
+            if (nameSet.contains(measure.getName())){
+                context.addResult(ResultLevel.ERROR, "There is duplicated measure's name:
" + measure.getName());
+                return true;
+            } else {
+                nameSet.add(measure.getName());
+            }
+        }
+        return false;
+    }
 }

http://git-wip-us.apache.org/repos/asf/kylin/blob/0b3b6f41/core-metadata/src/main/java/org/apache/kylin/measure/topn/TopNMeasureType.java
----------------------------------------------------------------------
diff --git a/core-metadata/src/main/java/org/apache/kylin/measure/topn/TopNMeasureType.java
b/core-metadata/src/main/java/org/apache/kylin/measure/topn/TopNMeasureType.java
index 39549ee..11a260a 100644
--- a/core-metadata/src/main/java/org/apache/kylin/measure/topn/TopNMeasureType.java
+++ b/core-metadata/src/main/java/org/apache/kylin/measure/topn/TopNMeasureType.java
@@ -239,8 +239,6 @@ public class TopNMeasureType extends MeasureType<TopNCounter<ByteArray>>
{
             }
         }
 
-        if (unmatchedDimensions.containsAll(literalCol) == false)
-            return null;
         if (digest.groupbyColumns.containsAll(literalCol) == false)
             return null;
 

http://git-wip-us.apache.org/repos/asf/kylin/blob/0b3b6f41/examples/test_case_data/localmeta/cube_desc/test_kylin_cube_with_slr_left_join_desc.json
----------------------------------------------------------------------
diff --git a/examples/test_case_data/localmeta/cube_desc/test_kylin_cube_with_slr_left_join_desc.json
b/examples/test_case_data/localmeta/cube_desc/test_kylin_cube_with_slr_left_join_desc.json
index 5dbee21..ff2af55 100644
--- a/examples/test_case_data/localmeta/cube_desc/test_kylin_cube_with_slr_left_join_desc.json
+++ b/examples/test_case_data/localmeta/cube_desc/test_kylin_cube_with_slr_left_join_desc.json
@@ -148,6 +148,23 @@
         "returntype": "hllc(12)"
       },
       "dependent_measure_ref": null
+    }, {
+      "name" : "TOP_SELLER",
+      "function" : {
+        "expression" : "TOP_N",
+        "parameter" : {
+          "type" : "column",
+          "value" : "PRICE",
+          "next_parameter" : {
+            "type" : "column",
+            "value" : "SELLER_ID",
+            "next_parameter" : null
+          }
+        },
+        "returntype" : "topn(100)",
+        "configuration": {"topn.encoding.SELLER_ID" : "int:4"}
+      },
+      "dependent_measure_ref" : null
     }
   ],
   "rowkey": {
@@ -221,6 +238,13 @@
             ]
           }
         ]
+      },
+      {
+        "name" : "F3",
+        "columns" : [ {
+          "qualifier" : "M",
+          "measure_refs" : [ "TOP_SELLER" ]
+        } ]
       }
     ]
   },


Mime
View raw message