Repository: kylin Updated Branches: refs/heads/master 59477501c -> 205471998
KYLIN-1595 add mass distinct count query Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/20547199 Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/20547199 Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/20547199 Branch: refs/heads/master Commit: 205471998d551bf5bc1988e0da73f5490f0a622c Parents: 5947750 Author: Hongbin Ma <mahong...@apache.org> Authored: Mon Apr 18 22:24:44 2016 +0800 Committer: Hongbin Ma <mahong...@apache.org> Committed: Mon Apr 18 22:24:52 2016 +0800 ---------------------------------------------------------------------- .../impl/threadpool/DefaultSchedulerTest.java | 2 -- .../apache/kylin/query/ITMassInQueryTest.java | 27 ++++++++++++++++- .../query/sql_massin_distinct/query01.sql | 31 ++++++++++++++++++++ 3 files changed, 57 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/20547199/core-job/src/test/java/org/apache/kylin/job/impl/threadpool/DefaultSchedulerTest.java ---------------------------------------------------------------------- diff --git a/core-job/src/test/java/org/apache/kylin/job/impl/threadpool/DefaultSchedulerTest.java b/core-job/src/test/java/org/apache/kylin/job/impl/threadpool/DefaultSchedulerTest.java index 6acbbe5..df521f9 100644 --- a/core-job/src/test/java/org/apache/kylin/job/impl/threadpool/DefaultSchedulerTest.java +++ b/core-job/src/test/java/org/apache/kylin/job/impl/threadpool/DefaultSchedulerTest.java @@ -37,12 +37,10 @@ import org.apache.kylin.job.SucceedTestExecutable; import org.apache.kylin.job.execution.DefaultChainedExecutable; import org.apache.kylin.job.execution.ExecutableState; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; /** */ -@Ignore public class DefaultSchedulerTest extends BaseSchedulerTest { @Test http://git-wip-us.apache.org/repos/asf/kylin/blob/20547199/kylin-it/src/test/java/org/apache/kylin/query/ITMassInQueryTest.java ---------------------------------------------------------------------- diff --git a/kylin-it/src/test/java/org/apache/kylin/query/ITMassInQueryTest.java b/kylin-it/src/test/java/org/apache/kylin/query/ITMassInQueryTest.java index a92e298..5f2db43 100644 --- a/kylin-it/src/test/java/org/apache/kylin/query/ITMassInQueryTest.java +++ b/kylin-it/src/test/java/org/apache/kylin/query/ITMassInQueryTest.java @@ -63,7 +63,7 @@ public class ITMassInQueryTest extends KylinTestBase { public void setup() throws Exception { ITKylinQueryTest.clean(); - ITKylinQueryTest.joinType = "inner"; + ITKylinQueryTest.joinType = "left"; ITKylinQueryTest.setupAll(); Configuration hconf = HadoopUtil.getCurrentConfiguration(); @@ -96,6 +96,31 @@ public class ITMassInQueryTest extends KylinTestBase { compare("src/test/resources/query/sql_massin", null, true); } + @Test + public void testMassInWithDistinctCount() throws Exception { + run("src/test/resources/query/sql_massin_distinct", null, true); + } + + protected void run(String queryFolder, String[] exclusiveQuerys, boolean needSort) throws Exception { + printInfo("---------- test folder: " + queryFolder); + Set<String> exclusiveSet = buildExclusiveSet(exclusiveQuerys); + + List<File> sqlFiles = getFilesFromFolder(new File(queryFolder), ".sql"); + for (File sqlFile : sqlFiles) { + String queryName = StringUtils.split(sqlFile.getName(), '.')[0]; + if (exclusiveSet.contains(queryName)) { + continue; + } + String sql = getTextFromFile(sqlFile); + + // execute Kylin + printInfo("Query Result from Kylin - " + queryName + " (" + queryFolder + ")"); + IDatabaseConnection kylinConn = new DatabaseConnection(cubeConnection); + ITable kylinTable = executeQuery(kylinConn, queryName, sql, needSort); + + } + } + protected void compare(String queryFolder, String[] exclusiveQuerys, boolean needSort) throws Exception { printInfo("---------- test folder: " + queryFolder); Set<String> exclusiveSet = buildExclusiveSet(exclusiveQuerys); http://git-wip-us.apache.org/repos/asf/kylin/blob/20547199/kylin-it/src/test/resources/query/sql_massin_distinct/query01.sql ---------------------------------------------------------------------- diff --git a/kylin-it/src/test/resources/query/sql_massin_distinct/query01.sql b/kylin-it/src/test/resources/query/sql_massin_distinct/query01.sql new file mode 100644 index 0000000..70afa87 --- /dev/null +++ b/kylin-it/src/test/resources/query/sql_massin_distinct/query01.sql @@ -0,0 +1,31 @@ +-- +-- 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(*) as TRANS_CNT , + count(DISTINCT test_kylin_fact.SELLER_ID), + 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 + inner JOIN edw.test_sites as test_sites + ON test_kylin_fact.lstg_site_id = test_sites.site_id + inner JOIN edw.test_seller_type_dim as test_seller_type_dim + ON test_kylin_fact.slr_segment_cd = test_seller_type_dim.seller_type_cd + where massin(test_kylin_fact.SELLER_ID,'vip_customers')