kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mahong...@apache.org
Subject kylin git commit: KYLIN-2030 enhancement
Date Sat, 08 Oct 2016 08:29:30 GMT
Repository: kylin
Updated Branches:
  refs/heads/orderedbytes 164288ccb -> adf1369af


KYLIN-2030 enhancement


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

Branch: refs/heads/orderedbytes
Commit: adf1369affd9615039cb5a5503fad092b60bf375
Parents: 164288c
Author: Hongbin Ma <mahongbin@apache.org>
Authored: Sat Oct 8 16:14:26 2016 +0800
Committer: Hongbin Ma <mahongbin@apache.org>
Committed: Sat Oct 8 16:14:26 2016 +0800

----------------------------------------------------------------------
 .../kylin/cube/CubeCapabilityChecker.java       | 38 +++++++++++++-------
 .../org/apache/kylin/cube/model/CubeDesc.java   | 10 +++---
 .../kylin/metadata/model/FunctionDesc.java      |  1 +
 .../test/resources/query/sql_lookup/query06.sql |  1 +
 .../test/resources/query/sql_lookup/query07.sql |  1 +
 5 files changed, 32 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/adf1369a/core-cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java b/core-cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java
index 1eada16..ee21b1c 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java
@@ -75,22 +75,34 @@ public class CubeCapabilityChecker {
         tryCustomMeasureTypes(unmatchedDimensions, unmatchedAggregations, digest, cube, result);
         //        }
 
-        // try dimension-as-measure
-        if (!unmatchedAggregations.isEmpty()) {
-            if (cube.getDescriptor().getFactTable().equals(digest.factTable)) {
+        //more tricks
+        if (cube.getDescriptor().getFactTable().equals(digest.factTable)) {
+            //for query-on-facttable
+            //1. dimension as measure
+
+            if (!unmatchedAggregations.isEmpty()) {
                 tryDimensionAsMeasures(unmatchedAggregations, digest, cube, result, cube.getDescriptor().listDimensionColumnsIncludingDerived());
-            } else {
-                //deal with query on lookup table, like https://issues.apache.org/jira/browse/KYLIN-2030
-                if (cube.getSegments().get(0).getSnapshots().containsKey(digest.factTable))
{
-                    TableDesc tableDesc = MetadataManager.getInstance(KylinConfig.getInstanceFromEnv()).getTableDesc(digest.factTable);
-                    Set<TblColRef> dimCols = Sets.newHashSet();
-                    for (ColumnDesc columnDesc : tableDesc.getColumns()) {
-                        dimCols.add(columnDesc.getRef());
-                    }
+            }
+        } else {
+            //for non query-on-facttable 
+            if (cube.getSegments().get(0).getSnapshots().containsKey(digest.factTable)) {
+                TableDesc tableDesc = MetadataManager.getInstance(KylinConfig.getInstanceFromEnv()).getTableDesc(digest.factTable);
+                Set<TblColRef> dimCols = Sets.newHashSet();
+                for (ColumnDesc columnDesc : tableDesc.getColumns()) {
+                    dimCols.add(columnDesc.getRef());
+                }
+
+                //1. dimension as measure, like max(cal_dt) or count( distinct col) from
lookup
+                if (!unmatchedAggregations.isEmpty()) {
                     tryDimensionAsMeasures(unmatchedAggregations, digest, cube, result, dimCols);
-                } else {
-                    logger.info("Skip tryDimensionAsMeasures because current cube {} does
not touch lookup table {} at all", cube.getName(), digest.factTable);
                 }
+
+                //2. more "dimensions" contributed by snapshot
+                if (!unmatchedDimensions.isEmpty()) {
+                    unmatchedDimensions.removeAll(dimCols);
+                }
+            } else {
+                logger.info("cube {} does not touch lookup table {} at all", cube.getName(),
digest.factTable);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/kylin/blob/adf1369a/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java b/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
index 4195451..7e055be 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
@@ -33,9 +33,9 @@ import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Set;
 import java.util.TreeSet;
+import java.util.Map.Entry;
 
 import javax.annotation.Nullable;
 
@@ -68,9 +68,9 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.google.common.base.Function;
 import com.google.common.collect.Collections2;
@@ -559,9 +559,7 @@ public class CubeDesc extends RootPersistentEntity implements IEngineAware
{
 
         // check all dimension columns are presented on rowkey
         List<TblColRef> dimCols = listDimensionColumnsExcludingDerived(true);
-        checkState(rowkey.getRowKeyColumns().length == dimCols.size(),
-                "RowKey columns count (%d) doesn't match dimensions columns count (%d)",
-                rowkey.getRowKeyColumns().length, dimCols.size());
+        checkState(rowkey.getRowKeyColumns().length == dimCols.size(), "RowKey columns count
(%d) doesn't match dimensions columns count (%d)", rowkey.getRowKeyColumns().length, dimCols.size());
 
         initDictionaryDesc();
     }
@@ -679,7 +677,7 @@ public class CubeDesc extends RootPersistentEntity implements IEngineAware
{
     private boolean hasSingle(ArrayList<Set<String>> dimsList) {
         boolean hasSingle = false;
         for (Set<String> dims : dimsList) {
-            if (dims.size() < 2)
+            if (dims.size() == 1)
                 hasSingle = true;
         }
         return hasSingle;

http://git-wip-us.apache.org/repos/asf/kylin/blob/adf1369a/core-metadata/src/main/java/org/apache/kylin/metadata/model/FunctionDesc.java
----------------------------------------------------------------------
diff --git a/core-metadata/src/main/java/org/apache/kylin/metadata/model/FunctionDesc.java
b/core-metadata/src/main/java/org/apache/kylin/metadata/model/FunctionDesc.java
index 36fff5c..27c7c69 100644
--- a/core-metadata/src/main/java/org/apache/kylin/metadata/model/FunctionDesc.java
+++ b/core-metadata/src/main/java/org/apache/kylin/metadata/model/FunctionDesc.java
@@ -120,6 +120,7 @@ public class FunctionDesc {
     }
 
     public MeasureType<?> getMeasureType() {
+        //like max(cal_dt)
         if (isDimensionAsMetric && !isCountDistinct()) {
             return null;
         }

http://git-wip-us.apache.org/repos/asf/kylin/blob/adf1369a/kylin-it/src/test/resources/query/sql_lookup/query06.sql
----------------------------------------------------------------------
diff --git a/kylin-it/src/test/resources/query/sql_lookup/query06.sql b/kylin-it/src/test/resources/query/sql_lookup/query06.sql
new file mode 100644
index 0000000..e2b8469
--- /dev/null
+++ b/kylin-it/src/test/resources/query/sql_lookup/query06.sql
@@ -0,0 +1 @@
+select max(cal_dt) as x from edw.test_cal_dt
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/kylin/blob/adf1369a/kylin-it/src/test/resources/query/sql_lookup/query07.sql
----------------------------------------------------------------------
diff --git a/kylin-it/src/test/resources/query/sql_lookup/query07.sql b/kylin-it/src/test/resources/query/sql_lookup/query07.sql
new file mode 100644
index 0000000..6be3439
--- /dev/null
+++ b/kylin-it/src/test/resources/query/sql_lookup/query07.sql
@@ -0,0 +1 @@
+select site_id,count(*) as y,count(DISTINCT site_name) as x from edw.test_sites group by
site_id


Mime
View raw message