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/10/05 15:32:04 UTC
incubator-kylin git commit: KYLIN-913 Fix PK explicitly declared as
derived dimension
Repository: incubator-kylin
Updated Branches:
refs/heads/1.x-staging 459a41d66 -> 071191169
KYLIN-913 Fix PK explicitly declared as derived dimension
Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/07119116
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/07119116
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/07119116
Branch: refs/heads/1.x-staging
Commit: 07119116989d346f33e39627a0828d7e031803d6
Parents: 459a41d
Author: Yang Li <li...@apache.org>
Authored: Mon Oct 5 21:31:48 2015 +0800
Committer: Yang Li <li...@apache.org>
Committed: Mon Oct 5 21:31:48 2015 +0800
----------------------------------------------------------------------
.../main/java/org/apache/kylin/cube/model/CubeDesc.java | 11 +++++++++++
1 file changed, 11 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/07119116/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 7f9252c..8fd2c4e 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
@@ -562,6 +562,17 @@ public class CubeDesc extends RootPersistentEntity {
private void initDerivedMap(TblColRef[] hostCols, DeriveType type, DimensionDesc dimension, TblColRef[] derivedCols, String[] extra) {
if (hostCols.length == 0 || derivedCols.length == 0)
throw new IllegalStateException("host/derived columns must not be empty");
+
+ // Although FK derives PK automatically, user unaware of this can declare PK as derived dimension explicitly.
+ // In that case, derivedCols[] will contain a FK which is transformed from the PK by initDimensionColRef().
+ // Must drop FK from derivedCols[] before continue.
+ for (int i = 0; i < derivedCols.length; i++) {
+ if (ArrayUtils.contains(hostCols, derivedCols[i])) {
+ derivedCols = (TblColRef[]) ArrayUtils.remove(derivedCols, i);
+ extra = (String[]) ArrayUtils.remove(extra, i);
+ i--;
+ }
+ }
Array<TblColRef> hostColArray = new Array<TblColRef>(hostCols);
List<DeriveInfo> infoList = hostToDerivedMap.get(hostColArray);