This is an automated email from the ASF dual-hosted git repository. xxyu pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/kylin.git
commit c9c723fe7164983476bcd39381ae216ea44f7867 Author: Zhong, Yanghong <nju_y...@apache.org> AuthorDate: Thu Apr 9 18:49:28 2020 +0800 KYLIN-4421 Add table alias field for root fact table in DataModelDesc --- .../java/org/apache/kylin/metadata/model/DataModelDesc.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/core-metadata/src/main/java/org/apache/kylin/metadata/model/DataModelDesc.java b/core-metadata/src/main/java/org/apache/kylin/metadata/model/DataModelDesc.java index 71f380a..e117176 100644 --- a/core-metadata/src/main/java/org/apache/kylin/metadata/model/DataModelDesc.java +++ b/core-metadata/src/main/java/org/apache/kylin/metadata/model/DataModelDesc.java @@ -31,6 +31,7 @@ import java.util.Objects; import java.util.Queue; import java.util.Set; +import com.google.common.base.Strings; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.kylin.common.KylinConfig; @@ -82,6 +83,9 @@ public class DataModelDesc extends RootPersistentEntity { @JsonProperty("fact_table") private String rootFactTable; + @JsonProperty("fact_table_alias") + private String rootFactTableAlias; + @JsonProperty("lookups") @JsonInclude(JsonInclude.Include.NON_NULL) private JoinTableDesc[] joinTables; @@ -403,7 +407,10 @@ public class DataModelDesc extends RootPersistentEntity { throw new IllegalStateException("Root fact table does not exist:" + rootFactTable); TableDesc rootDesc = tables.get(rootFactTable); - rootFactTableRef = new TableRef(this, rootDesc.getName(), rootDesc, false); + if (Strings.isNullOrEmpty(rootFactTableAlias)) { + rootFactTableAlias = rootDesc.getName(); + } + rootFactTableRef = new TableRef(this, rootFactTableAlias, rootDesc, false); addAlias(rootFactTableRef); factTableRefs.add(rootFactTableRef); @@ -601,8 +608,7 @@ public class DataModelDesc extends RootPersistentEntity { int orderedIndex = 0; Queue<JoinTableDesc> joinTableBuff = new ArrayDeque<JoinTableDesc>(); - TableDesc rootDesc = tables.get(rootFactTable); - joinTableBuff.addAll(fkMap.get(rootDesc.getName())); + joinTableBuff.addAll(fkMap.get(rootFactTableAlias)); while (!joinTableBuff.isEmpty()) { JoinTableDesc head = joinTableBuff.poll(); orderedJoinTables[orderedIndex++] = head; @@ -795,6 +801,7 @@ public class DataModelDesc extends RootPersistentEntity { copy.owner = orig.owner; copy.description = orig.description; copy.rootFactTable = orig.rootFactTable; + copy.rootFactTableAlias = orig.rootFactTableAlias; copy.joinTables = orig.joinTables; copy.dimensions = orig.dimensions; copy.metrics = orig.metrics;