This is an automated email from the ASF dual-hosted git repository. nic pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/kylin.git
The following commit(s) were added to refs/heads/master by this push: new 661f5ac #KYLIN-4158, limit not push down to storage scan level if group by is an expression 661f5ac is described below commit 661f5ac4cb938ad881bef4705348c72e8cf4e8ca Author: ZhengshuaiPENG <cosine...@hotmail.com> AuthorDate: Thu Sep 5 18:26:32 2019 +0800 #KYLIN-4158, limit not push down to storage scan level if group by is an expression --- .../storage/gtrecord/GTCubeStorageQueryBase.java | 13 +++++++++--- .../test/resources/query/sql_casewhen/query57.sql | 23 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/GTCubeStorageQueryBase.java b/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/GTCubeStorageQueryBase.java index 2273dbe..9b60076 100644 --- a/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/GTCubeStorageQueryBase.java +++ b/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/GTCubeStorageQueryBase.java @@ -103,7 +103,8 @@ public abstract class GTCubeStorageQueryBase implements IStorageQuery { return ITupleIterator.EMPTY_TUPLE_ITERATOR; return new SequentialCubeTupleIterator(scanners, request.getCuboid(), request.getDimensions(), - request.getDynGroups(), request.getGroups(), request.getMetrics(), returnTupleInfo, request.getContext(), sqlDigest); + request.getDynGroups(), request.getGroups(), request.getMetrics(), returnTupleInfo, + request.getContext(), sqlDigest); } public GTCubeStorageQueryRequest getStorageQueryRequest(StorageContext context, SQLDigest sqlDigest, @@ -177,7 +178,7 @@ public abstract class GTCubeStorageQueryBase implements IStorageQuery { // set limit push down enableStorageLimitIfPossible(cuboid, groups, dynGroups, derivedPostAggregation, groupsD, filterD, - loosenedColumnD, sqlDigest.aggregations, context); + loosenedColumnD, sqlDigest, context); // set whether to aggregate results from multiple partitions enableStreamAggregateIfBeneficial(cuboid, groupsD, context); // check query deadline @@ -421,7 +422,8 @@ public abstract class GTCubeStorageQueryBase implements IStorageQuery { private void enableStorageLimitIfPossible(Cuboid cuboid, Collection<TblColRef> groups, List<TblColRef> dynGroups, Set<TblColRef> derivedPostAggregation, Collection<TblColRef> groupsD, TupleFilter filter, - Set<TblColRef> loosenedColumnD, Collection<FunctionDesc> functionDescs, StorageContext context) { + Set<TblColRef> loosenedColumnD, SQLDigest sqlDigest, StorageContext context) { + Collection<FunctionDesc> functionDescs = sqlDigest.aggregations; StorageLimitLevel storageLimitLevel = StorageLimitLevel.LIMIT_ON_SCAN; @@ -469,6 +471,11 @@ public abstract class GTCubeStorageQueryBase implements IStorageQuery { } } + if (sqlDigest.groupByExpression) { + storageLimitLevel = StorageLimitLevel.NO_LIMIT; + logger.debug("storageLimitLevel set to NO_LIMIT because group by clause is an expression"); + } + context.applyLimitPushDown(cubeInstance, storageLimitLevel); } diff --git a/kylin-it/src/test/resources/query/sql_casewhen/query57.sql b/kylin-it/src/test/resources/query/sql_casewhen/query57.sql new file mode 100644 index 0000000..76ae649 --- /dev/null +++ b/kylin-it/src/test/resources/query/sql_casewhen/query57.sql @@ -0,0 +1,23 @@ +-- +-- 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 (CASE WHEN ("TEST_KYLIN_FACT"."LSTG_FORMAT_NAME" IN ('Auction', 'FP-GTC')) THEN 'Auction' ELSE "TEST_KYLIN_FACT"."LSTG_FORMAT_NAME" END) AS "LSTG_FORMAT_NAME__group_", + SUM("TEST_KYLIN_FACT"."PRICE") AS "sum_PRICE_ok" +FROM "TEST_KYLIN_FACT" "TEST_KYLIN_FACT" +GROUP BY (CASE WHEN ("TEST_KYLIN_FACT"."LSTG_FORMAT_NAME" IN ('Auction', 'FP-GTC')) THEN 'Auction' ELSE "TEST_KYLIN_FACT"."LSTG_FORMAT_NAME" END) +LIMIT 4 \ No newline at end of file