Repository: kylin
Updated Branches:
  refs/heads/yang-m1 ae51cf5cf -> 41fb735de


KYLIN-1595 refine test case

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/41fb735d
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/41fb735d
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/41fb735d

Branch: refs/heads/yang-m1
Commit: 41fb735de8521864659e384e5a0117c06da09f80
Parents: ae51cf5
Author: Hongbin Ma <[email protected]>
Authored: Mon Apr 18 18:56:26 2016 +0800
Committer: Hongbin Ma <[email protected]>
Committed: Mon Apr 18 22:28:10 2016 +0800

----------------------------------------------------------------------
 .../gridtable/AggregationCacheSpillTest.java    |  4 +--
 .../test_kylin_cube_with_slr_desc.json          |  2 +-
 ...test_kylin_cube_with_slr_left_join_desc.json |  2 +-
 .../apache/kylin/query/ITMassInQueryTest.java   | 27 ++++++++++++++++-
 .../query/sql_massin_distinct/query01.sql       | 31 ++++++++++++++++++++
 5 files changed, 61 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/41fb735d/core-cube/src/test/java/org/apache/kylin/gridtable/AggregationCacheSpillTest.java
----------------------------------------------------------------------
diff --git 
a/core-cube/src/test/java/org/apache/kylin/gridtable/AggregationCacheSpillTest.java
 
b/core-cube/src/test/java/org/apache/kylin/gridtable/AggregationCacheSpillTest.java
index 0e399dd..73e4908 100644
--- 
a/core-cube/src/test/java/org/apache/kylin/gridtable/AggregationCacheSpillTest.java
+++ 
b/core-cube/src/test/java/org/apache/kylin/gridtable/AggregationCacheSpillTest.java
@@ -88,7 +88,7 @@ public class AggregationCacheSpillTest {
             assertEquals(21, ((BigDecimal) returnRecord[4]).longValue());
             count++;
 
-            System.out.println(record);
+            //System.out.println(record);
         }
         assertEquals(DATA_CARDINALITY, count);
         scanner.close();
@@ -130,7 +130,7 @@ public class AggregationCacheSpillTest {
             assertEquals(84000, ((BigDecimal) returnRecord[4]).longValue());
             count++;
 
-            System.out.println(record);
+            //System.out.println(record);
         }
         assertEquals(10, count);
         scanner.close();

http://git-wip-us.apache.org/repos/asf/kylin/blob/41fb735d/examples/test_case_data/localmeta/cube_desc/test_kylin_cube_with_slr_desc.json
----------------------------------------------------------------------
diff --git 
a/examples/test_case_data/localmeta/cube_desc/test_kylin_cube_with_slr_desc.json
 
b/examples/test_case_data/localmeta/cube_desc/test_kylin_cube_with_slr_desc.json
index 7db40ec..4064fcb 100644
--- 
a/examples/test_case_data/localmeta/cube_desc/test_kylin_cube_with_slr_desc.json
+++ 
b/examples/test_case_data/localmeta/cube_desc/test_kylin_cube_with_slr_desc.json
@@ -158,7 +158,7 @@
     "includes" : [ "cal_dt", "categ_lvl2_name", "categ_lvl3_name", 
"leaf_categ_id", "lstg_format_name", "lstg_site_id", "meta_categ_name", 
"seller_id", "slr_segment_cd" ],
     "select_rule" : {
       "hierarchy_dims" : [ [ "META_CATEG_NAME", "CATEG_LVL2_NAME", 
"CATEG_LVL3_NAME" ] ],
-      "mandatory_dims" : [],
+      "mandatory_dims" : ["seller_id"],
       "joint_dims" : [ [ "lstg_format_name", "lstg_site_id", "slr_segment_cd" 
] ]
     }
   } ],

http://git-wip-us.apache.org/repos/asf/kylin/blob/41fb735d/examples/test_case_data/localmeta/cube_desc/test_kylin_cube_with_slr_left_join_desc.json
----------------------------------------------------------------------
diff --git 
a/examples/test_case_data/localmeta/cube_desc/test_kylin_cube_with_slr_left_join_desc.json
 
b/examples/test_case_data/localmeta/cube_desc/test_kylin_cube_with_slr_left_join_desc.json
index 33a7080..f0fe9c0 100644
--- 
a/examples/test_case_data/localmeta/cube_desc/test_kylin_cube_with_slr_left_join_desc.json
+++ 
b/examples/test_case_data/localmeta/cube_desc/test_kylin_cube_with_slr_left_join_desc.json
@@ -157,7 +157,7 @@
     "includes" : [ "cal_dt", "categ_lvl2_name", "categ_lvl3_name", 
"leaf_categ_id", "lstg_format_name", "lstg_site_id", "meta_categ_name", 
"seller_id", "slr_segment_cd" ],
     "select_rule" : {
       "hierarchy_dims" : [ [ "META_CATEG_NAME", "CATEG_LVL2_NAME", 
"CATEG_LVL3_NAME" ] ],
-      "mandatory_dims" : [ "seller_id" ],
+      "mandatory_dims" : [ ],
       "joint_dims" : [ [ "lstg_format_name", "lstg_site_id", "slr_segment_cd" 
] ]
     }
   } ],

http://git-wip-us.apache.org/repos/asf/kylin/blob/41fb735d/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/41fb735d/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') 

Reply via email to