You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2015/03/03 11:08:00 UTC

[04/26] incubator-kylin git commit: add right 'return type' when create measure in cube KYLIN-600

add right 'return type' when create measure in cube KYLIN-600


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

Branch: refs/heads/streaming
Commit: 0a5830ef96dc6c4aced85c3b2c7bbb177a764d6e
Parents: 80a5065
Author: jiazhong <ji...@ebay.com>
Authored: Fri Feb 27 16:49:20 2015 +0800
Committer: jiazhong <ji...@ebay.com>
Committed: Fri Feb 27 16:49:20 2015 +0800

----------------------------------------------------------------------
 .../kylin/rest/controller/CubeController.java   | 38 +++++++++++++++-----
 webapp/app/js/controllers/cubeEdit.js           |  7 ++--
 webapp/app/js/controllers/cubeSchema.js         | 26 ++++++++++----
 webapp/app/js/controllers/cubes.js              |  5 ++-
 webapp/app/js/filters/filter.js                 |  4 +--
 webapp/app/partials/cubeDesigner/measures.html  | 11 +++---
 6 files changed, 64 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/0a5830ef/server/src/main/java/org/apache/kylin/rest/controller/CubeController.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/kylin/rest/controller/CubeController.java b/server/src/main/java/org/apache/kylin/rest/controller/CubeController.java
index e624d45..be91436 100644
--- a/server/src/main/java/org/apache/kylin/rest/controller/CubeController.java
+++ b/server/src/main/java/org/apache/kylin/rest/controller/CubeController.java
@@ -18,10 +18,14 @@
 
 package org.apache.kylin.rest.controller;
 
-import com.codahale.metrics.annotation.Metered;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonMappingException;
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.kylin.common.KylinConfig;
 import org.apache.kylin.common.util.JsonUtil;
@@ -55,11 +59,17 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.AccessDeniedException;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
 
-import java.io.IOException;
-import java.net.UnknownHostException;
-import java.util.*;
+import com.codahale.metrics.annotation.Metered;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonMappingException;
 
 /**
  * CubeController is defined as Restful API entrance for UI.
@@ -348,7 +358,17 @@ public class CubeController extends BasicController {
             return cubeRequest;
         }
         try {
-            metaManager.updateDataModelDesc(modelDesc);
+
+            DataModelDesc existingModel = metaManager.getDataModelDesc(modelDesc.getName());
+            if (existingModel == null) {
+                metaManager.createDataModelDesc(modelDesc);
+            } else {
+
+                //ignore overwriting conflict checking before splict MODEL & CUBE
+                modelDesc.setLastModified(existingModel.getLastModified());
+                metaManager.updateDataModelDesc(modelDesc);
+            }
+
         } catch (IOException e) {
             // TODO Auto-generated catch block
             logger.error("Failed to deal with the request:" + e.getLocalizedMessage(), e);

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/0a5830ef/webapp/app/js/controllers/cubeEdit.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cubeEdit.js b/webapp/app/js/controllers/cubeEdit.js
index 0e05077..b632af1 100755
--- a/webapp/app/js/controllers/cubeEdit.js
+++ b/webapp/app/js/controllers/cubeEdit.js
@@ -38,11 +38,14 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams, $locatio
 
     $scope.getColumnType = function (_column,table){
         var columns = $scope.getColumnsByTable(table);
+        var type;
         angular.forEach(columns,function(column){
-            if(_column===column.name){
-                return column.type;
+            if(_column === column.name){
+                type = column.datatype;
+                return;
             }
         });
+        return type;
     };
 
     var ColFamily = function () {

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/0a5830ef/webapp/app/js/controllers/cubeSchema.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cubeSchema.js b/webapp/app/js/controllers/cubeSchema.js
index 4bb5762..7bad2d8 100755
--- a/webapp/app/js/controllers/cubeSchema.js
+++ b/webapp/app/js/controllers/cubeSchema.js
@@ -107,17 +107,31 @@ KylinApp.controller('CubeSchemaCtrl', function ($scope, QueryService, UserServic
         $scope.newMeasure = null;
     };
 
-    // !count !count distinct
-    $scope.measureParamValueUpdate = function(){
-        if(newMeasure.function.expression!=="COUNT"&&newMeasure.function.expression!=="COUNT_DISTINCT"){
+    //map right return type for param
+    $scope.measureReturnTypeUpdate = function(){
+        if($scope.newMeasure.function.expression!=="COUNT_DISTINCT"){
 
             var column = $scope.newMeasure.function.parameter.value;
+            var colType = $scope.getColumnType(column, $scope.metaModel.model.fact_table); // $scope.getColumnType defined in cubeEdit.js
 
 
-            switch(newMeasure.function.expression){
+            switch($scope.newMeasure.function.expression){
                 case "SUM":
-                    var colType = $scope.getColumnType(column, $scope.metaModel.model.fact_table);
-                    $log.log(colType);
+                    if(colType==="smallint"||colType==="int"||colType==="bigint"){
+                        $scope.newMeasure.function.returntype= 'bigint';
+                    }else{
+                        $scope.newMeasure.function.returntype= 'decimal';
+                    }
+                    break;
+                case "MIN":
+                case "MAX":
+                    $scope.newMeasure.function.returntype = colType;
+                    break;
+                case "COUNT":
+                    $scope.newMeasure.function.returntype = "bigint";
+                    break;
+                default:
+                    $scope.newMeasure.function.returntype = "";
                     break;
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/0a5830ef/webapp/app/js/controllers/cubes.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cubes.js b/webapp/app/js/controllers/cubes.js
index d576955..927fda1 100755
--- a/webapp/app/js/controllers/cubes.js
+++ b/webapp/app/js/controllers/cubes.js
@@ -77,7 +77,9 @@ KylinApp
 
         $scope.loadDetail = function (cube) {
             var defer = $q.defer();
-            if (!cube.detail) {
+            if(cube.detail){
+                defer.resolve(cube.detail);
+            } else {
                 CubeDescService.get({cube_name: cube.name}, {}, function (detail) {
                     if (detail.length > 0&&detail[0].hasOwnProperty("name")) {
                         cube.detail = detail[0];
@@ -95,6 +97,7 @@ KylinApp
                     }
                 });
             }
+
             return defer.promise;
         };
 

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/0a5830ef/webapp/app/js/filters/filter.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/filters/filter.js b/webapp/app/js/filters/filter.js
old mode 100644
new mode 100755
index d0d49fd..f3364c7
--- a/webapp/app/js/filters/filter.js
+++ b/webapp/app/js/filters/filter.js
@@ -108,7 +108,8 @@ KylinApp
         //convert GMT+0 time to specified Timezone
         return function(item,timezone,format){
 
-            if(angular.isUndefined(item)){
+            // undefined and 0 is not necessary to show
+            if(angular.isUndefined(item)||item===0){
                 return "";
             }
 
@@ -129,7 +130,6 @@ KylinApp
                     gmttimezone = timezone;
             }
 
-
             var localOffset = new Date().getTimezoneOffset();
             var convertedMillis = item;
             if(gmttimezone.indexOf("GMT+")!=-1){

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/0a5830ef/webapp/app/partials/cubeDesigner/measures.html
----------------------------------------------------------------------
diff --git a/webapp/app/partials/cubeDesigner/measures.html b/webapp/app/partials/cubeDesigner/measures.html
index 9a932bd..a260e28 100755
--- a/webapp/app/partials/cubeDesigner/measures.html
+++ b/webapp/app/partials/cubeDesigner/measures.html
@@ -111,6 +111,7 @@
                             <div class="col-xs-12 col-sm-6">
                                 <select class="form-control"
                                     ng-init="newMeasure.function.expression = (!!newMeasure.function.expression)?newMeasure.function.expression:cubeConfig.dftSelections.measureExpression" chosen ng-model="newMeasure.function.expression" required
+                                    ng-change="measureReturnTypeUpdate();"
                                     ng-options="me as me for me in cubeConfig.measureExpressions">
                                     <option value=""></option>
                                 </select>
@@ -146,7 +147,7 @@
                                 <select class="form-control" chosen
                                     ng-if="newMeasure.function.parameter.type == 'column'"
                                     ng-model="newMeasure.function.parameter.value"
-                                    ng-change="measureParamValueUpdate();"
+                                    ng-change="measureReturnTypeUpdate();"
                                     ng-options="columns.name as columns.name for columns in getColumnsByTable(metaModel.model.fact_table)" >
                                     <option value="">-- Select a Fact Table Column --</option>
                                 </select>
@@ -166,12 +167,8 @@
                                     <option value=""></option>
                                 </select>
                                 <span class="font-color-default"
-                                    ng-if="newMeasure.function.expression == 'COUNT'"
-                                    ng-init="newMeasure.function.returntype= 'bigint' "><b>&nbsp;&nbsp;BIGINT</b>
-                                </span>
-                                <span class="font-color-default"
-                                      ng-if="newMeasure.function.expression != 'COUNT_DISTINCT' && newMeasure.function.expression != 'COUNT' "
-                                     ><b>&nbsp;&nbsp;{{newMeasure.function.returntype}}</b>
+                                      ng-if="newMeasure.function.expression != 'COUNT_DISTINCT'"
+                                     ><b>&nbsp;&nbsp;{{newMeasure.function.returntype | uppercase}}</b>
                                 </span>
                             </div>
                         </div>