You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by xx...@apache.org on 2020/12/16 02:55:35 UTC

[kylin] branch master updated: KYLIN-4836 fix CubeMigrationCLI bug

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


The following commit(s) were added to refs/heads/master by this push:
     new 930daaf  KYLIN-4836 fix CubeMigrationCLI bug
930daaf is described below

commit 930daafe69a3b76106e40088574043517b74a46a
Author: chuxiao <ch...@didichuxing.com>
AuthorDate: Tue Dec 8 17:22:37 2020 +0800

    KYLIN-4836 fix CubeMigrationCLI bug
---
 .../main/java/org/apache/kylin/tool/CubeMigrationCLI.java   | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/tool/src/main/java/org/apache/kylin/tool/CubeMigrationCLI.java b/tool/src/main/java/org/apache/kylin/tool/CubeMigrationCLI.java
index 07dc8a1..91f9633 100644
--- a/tool/src/main/java/org/apache/kylin/tool/CubeMigrationCLI.java
+++ b/tool/src/main/java/org/apache/kylin/tool/CubeMigrationCLI.java
@@ -59,6 +59,7 @@ import org.apache.kylin.dict.lookup.SnapshotTable;
 import org.apache.kylin.engine.mr.JobBuilderSupport;
 import org.apache.kylin.metadata.MetadataConstants;
 import org.apache.kylin.metadata.model.DataModelDesc;
+import org.apache.kylin.metadata.model.DataModelManager;
 import org.apache.kylin.metadata.model.IStorageAware;
 import org.apache.kylin.metadata.model.SegmentStatusEnum;
 import org.apache.kylin.metadata.model.TableDesc;
@@ -456,6 +457,16 @@ public class CubeMigrationCLI extends AbstractApplication {
                 logger.info("Item: {} doesn't exist, ignore it.", item);
                 break;
             }
+            // dataModel`s project maybe be different with new project.
+            if (item.startsWith(ResourceStore.DATA_MODEL_DESC_RESOURCE_ROOT)) {
+                DataModelDesc dataModelDesc = srcStore.getResource(item, DataModelManager.getInstance(srcConfig).getDataModelSerializer());
+                if (dataModelDesc != null && dataModelDesc.getProjectName() != null && !dataModelDesc.getProjectName().equals(dstProject)) {
+                    dataModelDesc.setProjectName(dstProject);
+                    dstStore.putResource(item, dataModelDesc, res.lastModified(), DataModelManager.getInstance(srcConfig).getDataModelSerializer());
+                    logger.info("Item " + item + " is copied");
+                    break;
+                }
+            }
             dstStore.putResource(renameTableWithinProject(item), res.content(), res.lastModified());
             res.content().close();
             logger.info("Item " + item + " is copied");
@@ -655,7 +666,7 @@ public class CubeMigrationCLI extends AbstractApplication {
     }
 
     private String renameTableWithinProject(String srcItem) {
-        if (dstProject != null && srcItem.contains(ResourceStore.TABLE_RESOURCE_ROOT)) {
+        if (dstProject != null && srcItem.startsWith(ResourceStore.TABLE_RESOURCE_ROOT)) {
             String tableIdentity = TableDesc.parseResourcePath(srcItem).getTable();
             if (srcItem.contains(ResourceStore.TABLE_EXD_RESOURCE_ROOT))
                 return TableExtDesc.concatResourcePath(tableIdentity, dstProject);