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/06/11 08:37:35 UTC

[11/14] incubator-kylin git commit: use fk on fact table replace pk on lookup table when generate rowkey&aggregation group, distinct rowkey ang aggregation group

use fk on fact table replace pk on lookup table when generate rowkey&aggregation group,distinct rowkey ang aggregation group


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

Branch: refs/heads/0.7
Commit: f37360de7746628cac557014fec3eb5dc4dde8aa
Parents: 00d81f9
Author: jiazhong <ji...@ebay.com>
Authored: Wed Jun 10 20:31:53 2015 +0800
Committer: jiazhong <ji...@ebay.com>
Committed: Wed Jun 10 20:32:51 2015 +0800

----------------------------------------------------------------------
 webapp/app/js/controllers/cubeEdit.js          | 41 ++++++++++++++++++---
 webapp/app/partials/cubeDesigner/overview.html |  2 +-
 2 files changed, 36 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/f37360de/webapp/app/js/controllers/cubeEdit.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cubeEdit.js b/webapp/app/js/controllers/cubeEdit.js
index e371e3f..7f8cb27 100755
--- a/webapp/app/js/controllers/cubeEdit.js
+++ b/webapp/app/js/controllers/cubeEdit.js
@@ -233,7 +233,7 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams, $locatio
           }, function (request) {
             if (request.successful) {
               $scope.state.cubeSchema = request.cubeDescData;
-              
+
               SweetAlert.swal('', 'Created the cube successfully.', 'success');
 
               $location.path("/cubes");
@@ -299,9 +299,18 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams, $locatio
 
   function reGenerateRowKey() {
     $log.log("reGen rowkey & agg group");
+    var fk_pk = {};
     var tmpRowKeyColumns = [];
     var tmpAggregationItems = [];//put all aggregation item
     var hierarchyItemArray = [];//put all hierarchy items
+
+    // build fk_pk map
+    angular.forEach($scope.metaModel.model.lookups, function (_lookup, index) {
+      for(var i = 0;i< _lookup.join.foreign_key.length;i++){
+        fk_pk[_lookup.join.primary_key[i]] = _lookup.join.foreign_key[i];
+      }
+    });
+
     angular.forEach($scope.cubeMetaFrame.dimensions, function (dimension, index) {
 
       //derived column
@@ -325,11 +334,12 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams, $locatio
 
             tmpAggregationItems.push(fk);
           }
-        })
+        });
 
       }
+
       //normal column
-      else if (dimension.column && !dimension.hierarchy && dimension.column.length == 1) {
+      if (dimension.column && !dimension.hierarchy && dimension.column.length == 1) {
         for (var i = 0; i < tmpRowKeyColumns.length; i++) {
           if (tmpRowKeyColumns[i].column == dimension.column[0])
             break;
@@ -345,13 +355,21 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams, $locatio
         }
       }
       // hierarchy
-      if (dimension.hierarchy && dimension.column.length) {
+     else if (dimension.hierarchy && dimension.column.length) {
         var hierarchyUnit = [];
+
         angular.forEach(dimension.column, function (hier_column, index) {
+
+          //use fk instead of fk as rowkey and aggregation item in hierarchy
+          if(hier_column in fk_pk){
+            hier_column = fk_pk[hier_column];
+          }
+
           for (var i = 0; i < tmpRowKeyColumns.length; i++) {
             if (tmpRowKeyColumns[i].column == hier_column)
               break;
           }
+
           if (i == tmpRowKeyColumns.length) {
             tmpRowKeyColumns.push({
               "column": hier_column,
@@ -361,6 +379,7 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams, $locatio
             });
             tmpAggregationItems.push(hier_column);
           }
+
           if (hierarchyUnit.indexOf(hier_column) == -1) {
             hierarchyUnit.push(hier_column);
           }
@@ -370,10 +389,11 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams, $locatio
         }
       }
 
-    });
 
 
-    //rm mandatory column from aggregation item
+    });
+
+      //rm mandatory column from aggregation item
     angular.forEach($scope.cubeMetaFrame.rowkey.rowkey_columns, function (value, index) {
       if (value.mandatory) {
         tmpAggregationItems = _.filter(tmpAggregationItems, function (item) {
@@ -434,7 +454,16 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams, $locatio
         }
       });
 
+      //distinct hierarchyItem
       var hierarchyItems = hierarchyItemArray.join().split(",");
+      var _hierarchyItems = [];
+      angular.forEach(hierarchyItems, function (item, index) {
+        if (_hierarchyItems.indexOf(item) == -1) {
+          _hierarchyItems.push(item);
+        }
+      });
+      hierarchyItems = _hierarchyItems;
+
       var unHierarchyItems = increasedData(hierarchyItems, newUniqAggregationItem);
       //hierarchyItems
       var increasedDataGroups = sliceGroupItemToGroups(unHierarchyItems);

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/f37360de/webapp/app/partials/cubeDesigner/overview.html
----------------------------------------------------------------------
diff --git a/webapp/app/partials/cubeDesigner/overview.html b/webapp/app/partials/cubeDesigner/overview.html
index bbb5dc6..c1f6e71 100644
--- a/webapp/app/partials/cubeDesigner/overview.html
+++ b/webapp/app/partials/cubeDesigner/overview.html
@@ -34,7 +34,7 @@
                     <!--Fact Table-->
                     <tr>
                         <th>Fact Table</th>
-                        <td class="tb-breakword">{{cubeMetaFrame.fact_table}}</td>
+                        <td class="tb-breakword">{{metaModel.model.fact_table}}</td>
                     </tr>
                     <!--Lookup Table-->
                     <tr>