You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by ka...@apache.org on 2017/04/13 11:21:42 UTC

[16/50] [abbrv] kylin git commit: KYLIN-2449 skip rewriting if no realiztion in OLAPAggregateRel

KYLIN-2449 skip rewriting if no realiztion in OLAPAggregateRel

Signed-off-by: Yang Li <li...@apache.org>


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

Branch: refs/heads/KYLIN-2506
Commit: 4ddcc699ec807aea73cf4c158550678803f48eef
Parents: 9250d9b
Author: etherge <et...@163.com>
Authored: Wed Feb 15 15:18:18 2017 +0800
Committer: Yang Li <li...@apache.org>
Committed: Sun Apr 2 08:56:34 2017 +0800

----------------------------------------------------------------------
 .../kylin/metadata/model/ParameterDesc.java     |  1 +
 .../resources/query/sql_subquery/query16.sql    | 38 ++++++++++++++++++++
 .../kylin/query/relnode/OLAPAggregateRel.java   |  5 +--
 3 files changed, 42 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/4ddcc699/core-metadata/src/main/java/org/apache/kylin/metadata/model/ParameterDesc.java
----------------------------------------------------------------------
diff --git a/core-metadata/src/main/java/org/apache/kylin/metadata/model/ParameterDesc.java b/core-metadata/src/main/java/org/apache/kylin/metadata/model/ParameterDesc.java
index 5ba2f14..272c4ee 100644
--- a/core-metadata/src/main/java/org/apache/kylin/metadata/model/ParameterDesc.java
+++ b/core-metadata/src/main/java/org/apache/kylin/metadata/model/ParameterDesc.java
@@ -34,6 +34,7 @@ import com.google.common.collect.Sets;
 
 /**
  */
+@SuppressWarnings("serial")
 @JsonAutoDetect(fieldVisibility = Visibility.NONE, getterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
 public class ParameterDesc implements Serializable {
 

http://git-wip-us.apache.org/repos/asf/kylin/blob/4ddcc699/kylin-it/src/test/resources/query/sql_subquery/query16.sql
----------------------------------------------------------------------
diff --git a/kylin-it/src/test/resources/query/sql_subquery/query16.sql b/kylin-it/src/test/resources/query/sql_subquery/query16.sql
new file mode 100644
index 0000000..5477e54
--- /dev/null
+++ b/kylin-it/src/test/resources/query/sql_subquery/query16.sql
@@ -0,0 +1,38 @@
+--
+-- 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
+    t1.leaf_categ_id, COUNT(*) AS nums
+FROM
+    (SELECT
+        f.leaf_categ_id
+    FROM
+        test_kylin_fact f inner join TEST_CATEGORY_GROUPINGS o on f.leaf_categ_id = o.leaf_categ_id and f.LSTG_SITE_ID = o.site_id
+    WHERE
+        f.lstg_format_name = 'ABIN') t1
+    INNER JOIN
+    (SELECT
+        leaf_categ_id
+    FROM
+        test_kylin_fact f
+    INNER JOIN test_order o ON f.order_id = o.order_id
+    WHERE
+        buyer_id > 100) t2 ON t1.leaf_categ_id = t2.leaf_categ_id
+GROUP BY t1.leaf_categ_id
+ORDER BY nums, leaf_categ_id
+limit 100
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/kylin/blob/4ddcc699/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 2c75a14..d9385e9 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
@@ -279,7 +279,8 @@ public class OLAPAggregateRel extends Aggregate implements OLAPRel {
     @Override
     public void implementRewrite(RewriteImplementor implementor) {
         // only rewrite the innermost aggregation
-        if (!this.afterAggregate) {
+        boolean hasRealization = (null != this.context.realization);
+        if (hasRealization && !this.afterAggregate) {
             translateAggregation();
             buildRewriteFieldsAndMetricsColumns();
         }
@@ -287,7 +288,7 @@ public class OLAPAggregateRel extends Aggregate implements OLAPRel {
         implementor.visitChild(this, getInput());
 
         // only rewrite the innermost aggregation
-        if (!this.afterAggregate) {
+        if (hasRealization && !this.afterAggregate) {
             // rewrite the aggCalls
             this.rewriteAggCalls = new ArrayList<AggregateCall>(aggCalls.size());
             for (int i = 0; i < this.aggCalls.size(); i++) {