Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 27D68200BB4 for ; Tue, 27 Sep 2016 02:25:58 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 26700160AE7; Tue, 27 Sep 2016 00:25:58 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 137E9160AEF for ; Tue, 27 Sep 2016 02:25:56 +0200 (CEST) Received: (qmail 35563 invoked by uid 500); 27 Sep 2016 00:25:56 -0000 Mailing-List: contact commits-help@kylin.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@kylin.apache.org Delivered-To: mailing list commits@kylin.apache.org Received: (qmail 35149 invoked by uid 99); 27 Sep 2016 00:25:55 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Sep 2016 00:25:55 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2FA30E5CE1; Tue, 27 Sep 2016 00:25:55 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: liyang@apache.org To: commits@kylin.apache.org Date: Tue, 27 Sep 2016 00:26:07 -0000 Message-Id: <934245fb1c9049cc8bd44a686939aa77@git.apache.org> In-Reply-To: <5a1f85e1b2cd4e8085f0e6f886934efd@git.apache.org> References: <5a1f85e1b2cd4e8085f0e6f886934efd@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [14/50] [abbrv] kylin git commit: KYLIN-2029 distinct count query on lookup table archived-at: Tue, 27 Sep 2016 00:25:58 -0000 KYLIN-2029 distinct count query on lookup table Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/472e6d54 Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/472e6d54 Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/472e6d54 Branch: refs/heads/1.5.x-HBase1.x Commit: 472e6d547f2f04b8d6f92b9affa173a9685d3d2d Parents: 7d716df Author: Hongbin Ma Authored: Tue Sep 20 18:19:19 2016 +0800 Committer: Hongbin Ma Committed: Tue Sep 20 21:17:12 2016 +0800 ---------------------------------------------------------------------- .../test/resources/query/sql_lookup/query05.sql | 19 +++++++++++++++++++ .../kylin/query/relnode/OLAPAggregateRel.java | 8 ++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/472e6d54/kylin-it/src/test/resources/query/sql_lookup/query05.sql ---------------------------------------------------------------------- diff --git a/kylin-it/src/test/resources/query/sql_lookup/query05.sql b/kylin-it/src/test/resources/query/sql_lookup/query05.sql new file mode 100644 index 0000000..31fdf61 --- /dev/null +++ b/kylin-it/src/test/resources/query/sql_lookup/query05.sql @@ -0,0 +1,19 @@ +-- +-- 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 count(distinct META_CATEG_NAME) as CNT ,max(META_CATEG_NAME) as y from test_category_groupings http://git-wip-us.apache.org/repos/asf/kylin/blob/472e6d54/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 f55c86f..97efb27 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 @@ -265,7 +265,7 @@ public class OLAPAggregateRel extends Aggregate implements OLAPRel { implementor.visitChild(this, getInput()); // only rewrite the innermost aggregation - if (!this.afterAggregate && RewriteImplementor.needRewrite(this.context)) { + if (!this.afterAggregate) { // rewrite the aggCalls this.rewriteAggCalls = new ArrayList(aggCalls.size()); for (int i = 0; i < this.aggCalls.size(); i++) { @@ -354,11 +354,15 @@ public class OLAPAggregateRel extends Aggregate implements OLAPRel { } } + private boolean noPrecaculatedFieldsAvailable() { + return !this.context.hasPrecalculatedFields() || !RewriteImplementor.needRewrite(this.context); + } + private AggregateCall rewriteAggregateCall(AggregateCall aggCall, FunctionDesc func) { //if it's not a cube, then the "needRewriteField func" should not resort to any rewrite fields, // which do not exist at all - if (!this.context.hasPrecalculatedFields() && func.needRewriteField()) { + if (noPrecaculatedFieldsAvailable() && func.needRewriteField()) { logger.info(func + "skip rewriteAggregateCall because no pre-aggregated field available"); return aggCall; }