You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2015/06/23 13:11:29 UTC

incubator-kylin git commit: KYLIN-849 Couldn't query metrics on lookup table PK

Repository: incubator-kylin
Updated Branches:
  refs/heads/0.7-staging a487c6e45 -> 6ab09034d


KYLIN-849 Couldn't query metrics on lookup table PK

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

Branch: refs/heads/0.7-staging
Commit: 6ab09034d6edc50d879fd41afab3cf340883d82c
Parents: a487c6e
Author: shaofengshi <sh...@apache.org>
Authored: Tue Jun 23 19:10:56 2015 +0800
Committer: shaofengshi <sh...@apache.org>
Committed: Tue Jun 23 19:11:17 2015 +0800

----------------------------------------------------------------------
 .../kylin/cube/CubeCapabilityChecker.java       |  5 +++-
 .../kylin/query/relnode/OLAPAggregateRel.java   |  8 ++----
 .../AdjustForWeeklyMatchedRealization.java      |  2 +-
 query/src/test/resources/query/sql/query80.sql  | 27 ++++++++++++++++++++
 4 files changed, 34 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/6ab09034/cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java
----------------------------------------------------------------------
diff --git a/cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java b/cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java
index 27cf4ec..bd95d6e 100644
--- a/cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java
+++ b/cube/src/main/java/org/apache/kylin/cube/CubeCapabilityChecker.java
@@ -135,7 +135,10 @@ public class CubeCapabilityChecker {
             if (functionDesc.isCountDistinct()) // calcite can not handle distinct count
                 matched = false;
 
-            TblColRef col = functionDesc.selectTblColRef(metricColumns, cubeDesc.getFactTable());
+            TblColRef col = null;
+            if (functionDesc.getParameter().getColRefs().size() > 0)
+                col = functionDesc.getParameter().getColRefs().get(0);
+
             if (col == null || !cubeDesc.listDimensionColumnsIncludingDerived().contains(col)) {
                 matched = false;
             }

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/6ab09034/query/src/main/java/org/apache/kylin/query/relnode/OLAPAggregateRel.java
----------------------------------------------------------------------
diff --git a/query/src/main/java/org/apache/kylin/query/relnode/OLAPAggregateRel.java b/query/src/main/java/org/apache/kylin/query/relnode/OLAPAggregateRel.java
index 7cdb0b4..10d4150 100644
--- a/query/src/main/java/org/apache/kylin/query/relnode/OLAPAggregateRel.java
+++ b/query/src/main/java/org/apache/kylin/query/relnode/OLAPAggregateRel.java
@@ -18,12 +18,7 @@
 
 package org.apache.kylin.query.relnode;
 
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 import net.hydromatic.optiq.AggregateFunction;
 import net.hydromatic.optiq.FunctionParameter;
@@ -212,6 +207,7 @@ public class OLAPAggregateRel extends AggregateRelBase implements OLAPRel, Enume
                     parameter = new ParameterDesc();
                     parameter.setValue(column.getName());
                     parameter.setType("column");
+                    parameter.setColRefs(Arrays.asList(column));
                 }
             }
             FunctionDesc aggFunc = new FunctionDesc();

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/6ab09034/query/src/main/java/org/apache/kylin/query/routing/RoutingRules/AdjustForWeeklyMatchedRealization.java
----------------------------------------------------------------------
diff --git a/query/src/main/java/org/apache/kylin/query/routing/RoutingRules/AdjustForWeeklyMatchedRealization.java b/query/src/main/java/org/apache/kylin/query/routing/RoutingRules/AdjustForWeeklyMatchedRealization.java
index df58944..465d162 100644
--- a/query/src/main/java/org/apache/kylin/query/routing/RoutingRules/AdjustForWeeklyMatchedRealization.java
+++ b/query/src/main/java/org/apache/kylin/query/routing/RoutingRules/AdjustForWeeklyMatchedRealization.java
@@ -79,7 +79,7 @@ public class AdjustForWeeklyMatchedRealization extends RoutingRule {
             FunctionDesc functionDesc = it.next();
             if (!availableAggregations.contains(functionDesc)) {
                 // try to convert the metric to dimension to see if it works
-                TblColRef col = functionDesc.selectTblColRef(olapContext.metricsColumns, factTableName);
+                TblColRef col = functionDesc.getParameter().getColRefs().get(0);
                 functionDesc.setDimensionAsMetric(true);
                 olapContext.rewriteFields.remove(functionDesc.getRewriteFieldName());
                 if (col != null) {

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/6ab09034/query/src/test/resources/query/sql/query80.sql
----------------------------------------------------------------------
diff --git a/query/src/test/resources/query/sql/query80.sql b/query/src/test/resources/query/sql/query80.sql
new file mode 100644
index 0000000..990e6dc
--- /dev/null
+++ b/query/src/test/resources/query/sql/query80.sql
@@ -0,0 +1,27 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+SELECT
+ min(test_cal_dt.cal_dt) as mmin
+ ,max(test_cal_dt.cal_dt) as mmax
+ FROM test_kylin_fact
+ inner JOIN edw.test_cal_dt as test_cal_dt
+ ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt
+ inner JOIN test_category_groupings
+ ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id
+ AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id 
\ No newline at end of file