You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by zh...@apache.org on 2015/06/11 04:54:45 UTC

incubator-kylin git commit: use fk on fact table replace pk on lookup table when generate rowkey

Repository: incubator-kylin
Updated Branches:
  refs/heads/0.8.0 006e68e37 -> 090e90884


use fk on fact table replace pk on lookup table when generate rowkey


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

Branch: refs/heads/0.8.0
Commit: 090e908844af00cd632c632464ced4707d9022e2
Parents: 006e68e
Author: jiazhong <ji...@ebay.com>
Authored: Thu Jun 11 10:54:03 2015 +0800
Committer: jiazhong <ji...@ebay.com>
Committed: Thu Jun 11 10:54:32 2015 +0800

----------------------------------------------------------------------
 webapp/app/js/controllers/cubeEdit.js | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/090e9088/webapp/app/js/controllers/cubeEdit.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cubeEdit.js b/webapp/app/js/controllers/cubeEdit.js
index cf8ab95..4c3a82c 100755
--- a/webapp/app/js/controllers/cubeEdit.js
+++ b/webapp/app/js/controllers/cubeEdit.js
@@ -286,11 +286,19 @@ 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
         angular.forEach(cubesManager.cubeMetaFrame.dimensions, function (dimension, index) {
 
+          // 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];
+            }
+          });
+
            //derived column
             if(dimension.derived&&dimension.derived.length){
                 var lookup = _.find($scope.metaModel.model.lookups,function(lookup){return lookup.table==dimension.table});
@@ -333,6 +341,12 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams, $locatio
             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;
@@ -419,7 +433,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);