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 2016/03/23 10:14:49 UTC
[05/50] [abbrv] kylin git commit: KYLIN-1471 - LIMIT after having
clause should not be pushed down to storage context
KYLIN-1471 - LIMIT after having clause should not be pushed down to storage context
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/2f44970d
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/2f44970d
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/2f44970d
Branch: refs/heads/1.5.x-HBase1.1.3
Commit: 2f44970d28318a21c16aaa8f28e844c5d88f5e3d
Parents: b9a3418
Author: Hongbin Ma <ma...@apache.org>
Authored: Fri Mar 4 16:00:11 2016 +0800
Committer: Hongbin Ma <ma...@apache.org>
Committed: Fri Mar 4 16:01:04 2016 +0800
----------------------------------------------------------------------
.../resources/query/sql_tableau/query29.sql | 29 ++++++++++++++++++++
.../apache/kylin/query/relnode/OLAPContext.java | 1 +
.../kylin/query/relnode/OLAPFilterRel.java | 2 ++
.../kylin/query/relnode/OLAPLimitRel.java | 21 ++++++++------
4 files changed, 44 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/2f44970d/kylin-it/src/test/resources/query/sql_tableau/query29.sql
----------------------------------------------------------------------
diff --git a/kylin-it/src/test/resources/query/sql_tableau/query29.sql b/kylin-it/src/test/resources/query/sql_tableau/query29.sql
new file mode 100644
index 0000000..0858087
--- /dev/null
+++ b/kylin-it/src/test/resources/query/sql_tableau/query29.sql
@@ -0,0 +1,29 @@
+--
+-- 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 *
+ FROM (
+ select test_kylin_fact.lstg_format_name, test_cal_dt.week_beg_dt,sum(test_kylin_fact.price) as GMV
+ , count(*) as TRANS_CNT
+ 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
+ where test_cal_dt.week_beg_dt between DATE '2013-05-01' and DATE '2013-08-01'
+ group by test_kylin_fact.lstg_format_name, test_cal_dt.week_beg_dt
+ ) "TableauSQL"
+ LIMIT 1
http://git-wip-us.apache.org/repos/asf/kylin/blob/2f44970d/query/src/main/java/org/apache/kylin/query/relnode/OLAPContext.java
----------------------------------------------------------------------
diff --git a/query/src/main/java/org/apache/kylin/query/relnode/OLAPContext.java b/query/src/main/java/org/apache/kylin/query/relnode/OLAPContext.java
index 6de1790..431328f 100644
--- a/query/src/main/java/org/apache/kylin/query/relnode/OLAPContext.java
+++ b/query/src/main/java/org/apache/kylin/query/relnode/OLAPContext.java
@@ -103,6 +103,7 @@ public class OLAPContext {
public OLAPTableScan firstTableScan = null; // to be fact table scan except "select * from lookupTable"
public TupleInfo returnTupleInfo = null;
public boolean afterAggregate = false;
+ public boolean afterSkippedFilter = false;
public boolean afterJoin = false;
public boolean hasJoin = false;
http://git-wip-us.apache.org/repos/asf/kylin/blob/2f44970d/query/src/main/java/org/apache/kylin/query/relnode/OLAPFilterRel.java
----------------------------------------------------------------------
diff --git a/query/src/main/java/org/apache/kylin/query/relnode/OLAPFilterRel.java b/query/src/main/java/org/apache/kylin/query/relnode/OLAPFilterRel.java
index 7b8bfdb..a847890 100644
--- a/query/src/main/java/org/apache/kylin/query/relnode/OLAPFilterRel.java
+++ b/query/src/main/java/org/apache/kylin/query/relnode/OLAPFilterRel.java
@@ -271,6 +271,8 @@ public class OLAPFilterRel extends Filter implements OLAPRel {
// only translate where clause and don't translate having clause
if (!context.afterAggregate) {
translateFilter(context);
+ } else {
+ context.afterSkippedFilter = true;//having clause is skipped
}
}
http://git-wip-us.apache.org/repos/asf/kylin/blob/2f44970d/query/src/main/java/org/apache/kylin/query/relnode/OLAPLimitRel.java
----------------------------------------------------------------------
diff --git a/query/src/main/java/org/apache/kylin/query/relnode/OLAPLimitRel.java b/query/src/main/java/org/apache/kylin/query/relnode/OLAPLimitRel.java
index 572a5c7..82aa9de 100644
--- a/query/src/main/java/org/apache/kylin/query/relnode/OLAPLimitRel.java
+++ b/query/src/main/java/org/apache/kylin/query/relnode/OLAPLimitRel.java
@@ -73,16 +73,19 @@ public class OLAPLimitRel extends SingleRel implements OLAPRel {
implementor.visitChild(getInput(), this);
this.columnRowType = buildColumnRowType();
-
this.context = implementor.getContext();
- Number limitValue = (Number) (((RexLiteral) localFetch).getValue());
- int limit = limitValue.intValue();
- this.context.storageContext.setLimit(limit);
- this.context.limit = limit;
- if(localOffset != null) {
- Number offsetValue = (Number) (((RexLiteral) localOffset).getValue());
- int offset = offsetValue.intValue();
- this.context.storageContext.setOffset(offset);
+
+ if (!context.afterSkippedFilter) {
+ Number limitValue = (Number) (((RexLiteral) localFetch).getValue());
+ int limit = limitValue.intValue();
+ this.context.storageContext.setLimit(limit);
+ this.context.limit = limit;
+
+ if (localOffset != null) {
+ Number offsetValue = (Number) (((RexLiteral) localOffset).getValue());
+ int offset = offsetValue.intValue();
+ this.context.storageContext.setOffset(offset);
+ }
}
}