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/05 11:47:34 UTC

incubator-kylin git commit: rollback KYLIN-658

Repository: incubator-kylin
Updated Branches:
  refs/heads/0.8.0 9f7567a43 -> 8ef41be4e


rollback KYLIN-658


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

Branch: refs/heads/0.8.0
Commit: 8ef41be4ec6ba871bc54484fb23843ea86f35bcd
Parents: 9f7567a
Author: Li, Yang <ya...@ebay.com>
Authored: Fri Jun 5 17:47:21 2015 +0800
Committer: Li, Yang <ya...@ebay.com>
Committed: Fri Jun 5 17:47:21 2015 +0800

----------------------------------------------------------------------
 .../org/apache/kylin/cube/model/CubeDesc.java   | 23 ++++++++++++++------
 1 file changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/8ef41be4/cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
----------------------------------------------------------------------
diff --git a/cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java b/cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
index 95fe18a..f91aff1 100644
--- a/cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
+++ b/cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
@@ -467,7 +467,7 @@ public class CubeDesc extends RootPersistentEntity {
             // init dimension columns
             ArrayList<TblColRef> dimCols = Lists.newArrayList();
             String[] colStrs = dim.getColumn();
-            
+
             // when column is omitted, special case
             if (colStrs == null && dim.isDerived() || ArrayUtils.contains(colStrs, "{FK}")) {
                 for (TblColRef col : join.getForeignKeyColumns()) {
@@ -478,18 +478,18 @@ public class CubeDesc extends RootPersistentEntity {
             else {
                 if (colStrs == null || colStrs.length == 0)
                     throw new IllegalStateException("Dimension column must not be blank " + dim);
-                
+
                 for (String colStr : colStrs) {
                     dimCols.add(initDimensionColRef(dim, colStr));
                 }
-                
+
                 // fill back column ref in hierarchy
                 if (dim.isHierarchy()) {
                     for (int i = 0; i < dimCols.size(); i++)
                         dim.getHierarchy()[i].setColumnRef(dimCols.get(i));
                 }
             }
-            
+
             TblColRef[] dimColArray = (TblColRef[]) dimCols.toArray(new TblColRef[dimCols.size()]);
             dim.setColumnRefs(dimColArray);
 
@@ -573,8 +573,17 @@ public class CubeDesc extends RootPersistentEntity {
         ColumnDesc col = table.findColumnByName(colName);
         if (col == null)
             throw new IllegalArgumentException("No column '" + colName + "' found in table " + table);
-        
+
         TblColRef ref = new TblColRef(col);
+        
+        // always use FK instead PK, FK could be shared by more than one lookup tables
+        JoinDesc join = dim.getJoin();
+        if (join != null) {
+            int idx = ArrayUtils.indexOf(join.getPrimaryKeyColumns(), ref);
+            if (idx >= 0) {
+                ref = join.getForeignKeyColumns()[idx];
+            }
+        }
         return initDimensionColRef(ref);
     }
 
@@ -607,7 +616,7 @@ public class CubeDesc extends RootPersistentEntity {
             if (m.getDependentMeasureRef() != null) {
                 m.setDependentMeasureRef(m.getDependentMeasureRef().toUpperCase());
             }
-            
+
             FunctionDesc f = m.getFunction();
             f.setExpression(f.getExpression().toUpperCase());
             f.setReturnDataType(DataType.getInstance(f.getReturnType()));
@@ -626,7 +635,7 @@ public class CubeDesc extends RootPersistentEntity {
                 if (colRefs.isEmpty() == false)
                     p.setColRefs(colRefs);
             }
-            
+
             // verify holistic count distinct as a dependent measure
             if (m.getFunction().isHolisticCountDistinct() && StringUtils.isBlank(m.getDependentMeasureRef())) {
                 throw new IllegalStateException(m + " is a holistic count distinct but it has no DependentMeasureRef defined!");