kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mahong...@apache.org
Subject [1/4] kylin git commit: KYLIN-2024 kylin TopN only support the first measure [Forced Update!]
Date Wed, 02 Nov 2016 09:56:40 GMT
Repository: kylin
Updated Branches:
  refs/heads/yang21-hbase1.x 4599edfc6 -> 6770b421a (forced update)


KYLIN-2024 kylin TopN only support the first measure


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

Branch: refs/heads/yang21-hbase1.x
Commit: 37fbf0c1e22160b4da6ab88d59507a5e887d187c
Parents: f522e2b
Author: shaofengshi <shaofengshi@apache.org>
Authored: Wed Nov 2 13:20:10 2016 +0800
Committer: shaofengshi <shaofengshi@apache.org>
Committed: Wed Nov 2 16:07:13 2016 +0800

----------------------------------------------------------------------
 .../kylin/measure/topn/TopNMeasureType.java      | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/37fbf0c1/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 12343b3..3974a4f 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
@@ -39,8 +39,8 @@ import org.apache.kylin.metadata.datatype.DataTypeSerializer;
 import org.apache.kylin.metadata.model.FunctionDesc;
 import org.apache.kylin.metadata.model.MeasureDesc;
 import org.apache.kylin.metadata.model.TblColRef;
-import org.apache.kylin.metadata.realization.SQLDigest;
 import org.apache.kylin.metadata.realization.CapabilityResult.CapabilityInfluence;
+import org.apache.kylin.metadata.realization.SQLDigest;
 import org.apache.kylin.metadata.tuple.Tuple;
 import org.apache.kylin.metadata.tuple.TupleInfo;
 import org.slf4j.Logger;
@@ -312,15 +312,16 @@ public class TopNMeasureType extends MeasureType<TopNCounter<ByteArray>>
{
 
     @Override
     public void adjustSqlDigest(List<MeasureDesc> measureDescs, SQLDigest sqlDigest)
{
+        if (sqlDigest.aggregations.size() > 1) {
+            return;
+        }
+
         for (MeasureDesc measureDesc : measureDescs) {
             FunctionDesc topnFunc = measureDesc.getFunction();
             List<TblColRef> topnLiteralCol = getTopNLiteralColumn(topnFunc);
 
-            if (sqlDigest.groupbyColumns.containsAll(topnLiteralCol) == false)
-                return;
-
-            if (sqlDigest.aggregations.size() > 1) {
-                return;
+            if (sqlDigest.groupbyColumns.containsAll(topnLiteralCol) == false) {
+                continue;
             }
 
             if (sqlDigest.aggregations.size() > 0) {
@@ -329,12 +330,18 @@ public class TopNMeasureType extends MeasureType<TopNCounter<ByteArray>>
{
                     logger.warn("When query with topN, only SUM/Count function is allowed.");
                     return;
                 }
+
+                if (isTopNCompatibleSum(measureDesc.getFunction(), origFunc) == false) {
+                    continue;
+                }
+
                 logger.info("Rewrite function " + origFunc + " to " + topnFunc);
             }
 
             sqlDigest.aggregations = Lists.newArrayList(topnFunc);
             sqlDigest.groupbyColumns.removeAll(topnLiteralCol);
             sqlDigest.metricColumns.addAll(topnLiteralCol);
+            break;
         }
     }
 


Mime
View raw message