Repository: kylin
Updated Branches:
  refs/heads/2.1.x 1a98eff63 -> 4cb5c2209


KYLIN 2616 COUNT DISTINCT SUPPORT MULTIPLE COLUMN


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/4cb5c220
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/4cb5c220
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/4cb5c220

Branch: refs/heads/2.1.x
Commit: 4cb5c2209d744e5ba6ff5db4bfc75b46cccac7f1
Parents: 1a98eff
Author: chenzhx <346839...@qq.com>
Authored: Thu Jul 13 16:10:14 2017 +0800
Committer: chenzhx <346839...@qq.com>
Committed: Wed Jul 19 17:54:56 2017 +0800

----------------------------------------------------------------------
 webapp/app/js/controllers/cubeMeasures.js      | 44 ++++++++++++++++-----
 webapp/app/partials/cubeDesigner/measures.html | 18 ++++-----
 2 files changed, 44 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/4cb5c220/webapp/app/js/controllers/cubeMeasures.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cubeMeasures.js 
b/webapp/app/js/controllers/cubeMeasures.js
index 824e2ca..0a012dd 100644
--- a/webapp/app/js/controllers/cubeMeasures.js
+++ b/webapp/app/js/controllers/cubeMeasures.js
@@ -106,6 +106,12 @@ KylinApp.controller('CubeMeasuresCtrl', function ($scope, 
$modal,MetaModel,cubes
         }
       };
     }
+    if ($scope.newMeasure.function.expression === 'COUNT_DISTINCT') {
+      $scope.convertedColumns=[];
+      if ($scope.newMeasure.function.parameter.next_parameter) {
+        $scope.recursion($scope.newMeasure.function.parameter.next_parameter, 
$scope.convertedColumns)
+      }
+    }
   };
 
 
@@ -213,13 +219,34 @@ KylinApp.controller('CubeMeasuresCtrl', function ($scope, 
$modal,MetaModel,cubes
           $scope.newMeasure.function.configuration[versionKey]=version;
           });
     }
+    if ($scope.newMeasure.function.expression === 'COUNT_DISTINCT' ) {
+
+      var hasExisted = [];
+
+      for (var column in $scope.convertedColumns){
+        if(hasExisted.indexOf($scope.convertedColumns[column].name)==-1){
+          hasExisted.push($scope.convertedColumns[column].name);
+        }
+        else{
+          SweetAlert.swal('', 'The column named 
['+$scope.convertedColumns[column].name+'] already exits.', 'warning');
+          return false;
+        }
+      }
+      $scope.nextPara.next_parameter={};
+      if ($scope.convertedColumns.length > 0) {
+        $scope.groupby($scope.nextPara);
+      } else {
+        $scope.nextPara=null;
+        $scope.newMeasure.function.parameter.next_parameter=null;
+      }
+    }
 
     if ($scope.isNameDuplicated($scope.cubeMetaFrame.measures, 
$scope.newMeasure) == true) {
       SweetAlert.swal('', 'The measure name: ' + $scope.newMeasure.name + ' is 
duplicated', 'warning');
       return false;
     }
 
-    if($scope.nextPara.value!=="" && ($scope.newMeasure.function.expression == 
'EXTENDED_COLUMN' || $scope.newMeasure.function.expression == 'TOP_N')){
+    if($scope.nextPara && $scope.nextPara.value!=="" && 
($scope.newMeasure.function.expression == 'EXTENDED_COLUMN' || 
$scope.newMeasure.function.expression == 
'TOP_N'||$scope.newMeasure.function.expression == 'COUNT_DISTINCT')){
       $scope.newMeasure.function.parameter.next_parameter = 
jQuery.extend(true,{},$scope.nextPara);
     }
 
@@ -295,14 +322,13 @@ KylinApp.controller('CubeMeasuresCtrl', function ($scope, 
$modal,MetaModel,cubes
       return false;
     }
   }
-  $scope.converted = function (next_parameter) {
-    if (next_parameter != null) {
-      $scope.groupby.push(next_parameter.value);
-      converted(next_parameter.next_parameter)
-    }
-    else {
-      $scope.groupby.push(next_parameter.value);
-      return false;
+
+  $scope.recursion = function (parameter, list) {
+    list.push({name: parameter.value})
+    if (parameter.next_parameter) {
+      $scope.recursion(parameter.next_parameter, list)
+    } else {
+      return
     }
   }
 

http://git-wip-us.apache.org/repos/asf/kylin/blob/4cb5c220/webapp/app/partials/cubeDesigner/measures.html
----------------------------------------------------------------------
diff --git a/webapp/app/partials/cubeDesigner/measures.html 
b/webapp/app/partials/cubeDesigner/measures.html
index df69b78..89c7142 100755
--- a/webapp/app/partials/cubeDesigner/measures.html
+++ b/webapp/app/partials/cubeDesigner/measures.html
@@ -218,22 +218,22 @@
                       </div>
 
                       <!--Group by Column-->
-                      <div class="form-group" 
ng-if="newMeasure.function.expression == 'TOP_N'" >
+                      <div class="form-group" 
ng-if="newMeasure.function.expression === 
'TOP_N'||newMeasure.function.expression === 'COUNT_DISTINCT'" >
                         <div class="row">
                           <label class="col-xs-12 col-sm-3 control-label 
no-padding-right font-color-default">
                             <b>Group by Column</b>
                           </label>
                           <div class="form-group large-popover" >
                               <div class="box-body">
-                                <table style="margin-left:width:92%"
+                                <table style="width:92%"
                                        class="table table-hover table-bordered 
list">
                                   <thead>
                                   <tr>
                                     <th  style="width:40px;">ID</th>
                                     <th  style="width:300px;">Column</th>
-                                    <th  style="width:140px;">Encoding</th>
-                                    <th >Length</th>
-                                    <th ng-if="state.mode=='edit'"></th>
+                                    <th  style="width:140px;" 
ng-if="newMeasure.function.expression === 'TOP_N'">Encoding</th>
+                                    <th ng-if="newMeasure.function.expression 
=== 'TOP_N'">Length</th>
+                                    <th style="width:50px;" 
ng-if="state.mode=='edit'"></th>
                                   </tr>
                                   </thead>
 
@@ -248,22 +248,22 @@
                                     </td>
                                     <!--Column Name -->
                                     <td>
-                                      <select class="form-control" chosen 
ng-if="nextPara.type !== 'constant'" required
+                                      <select style="width:270px"  chosen 
ng-if="nextPara.type !== 'constant'" required
                                               ng-model="groupby_column.name"
                                               ng-options="column as column for 
column in getAllModelDimColumns()" >
                                         <option value="">--Select A 
Column--</option>
                                       </select>
                                     </td>
                                     <!--Column Encoding -->
-                                    <td>
-                                      <select ng-if="state.mode=='edit'" 
style="width: 100%"
+                                    <td ng-if="newMeasure.function.expression 
=== 'TOP_N'">
+                                      <select ng-if="state.mode=='edit'" 
style="width:100%"
                                               chosen 
ng-model="groupby_column.encoding"
                                               
ng-change="refreshGroupBy(convertedColumns,$index,groupby_column)"
                                               ng-options="dt.value as dt.name 
for dt in getEncodings(groupby_column.name)">
                                         <option value=""></option>
                                       </select>
                                     </td>
-                                    <td>
+                                    <td ng-if="newMeasure.function.expression 
=== 'TOP_N'">
                                       <!--Column Length -->
                                       <input type="text" class="form-control" 
placeholder="Column Length.." ng-if="state.mode=='edit'"
                                              tooltip="group by column 
length.." tooltip-trigger="focus"

Reply via email to