kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhongj...@apache.org
Subject kylin git commit: KYLIN-2084 Unload sample table failed
Date Mon, 17 Oct 2016 05:20:28 GMT
Repository: kylin
Updated Branches:
  refs/heads/master c3bfd770a -> ef44b7f68


KYLIN-2084 Unload sample table failed

Signed-off-by: Jason <jiatuer@163.com>


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

Branch: refs/heads/master
Commit: ef44b7f6873b2e5ac55243818877474cdc0376d8
Parents: c3bfd77
Author: Jason <jiatuer@163.com>
Authored: Mon Oct 17 13:18:57 2016 +0800
Committer: Jason <jiatuer@163.com>
Committed: Mon Oct 17 13:20:16 2016 +0800

----------------------------------------------------------------------
 .../java/org/apache/kylin/metadata/MetadataManager.java   | 10 ++++++++++
 .../org/apache/kylin/rest/controller/TableController.java |  3 +++
 .../java/org/apache/kylin/rest/service/ModelService.java  |  7 +++++++
 3 files changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/ef44b7f6/core-metadata/src/main/java/org/apache/kylin/metadata/MetadataManager.java
----------------------------------------------------------------------
diff --git a/core-metadata/src/main/java/org/apache/kylin/metadata/MetadataManager.java b/core-metadata/src/main/java/org/apache/kylin/metadata/MetadataManager.java
index 92d41b9..e0c78ce 100644
--- a/core-metadata/src/main/java/org/apache/kylin/metadata/MetadataManager.java
+++ b/core-metadata/src/main/java/org/apache/kylin/metadata/MetadataManager.java
@@ -496,6 +496,16 @@ public class MetadataManager {
         return false;
     }
 
+    public List<String> getModelsUsingTable(String tableName, String projectName) throws
IOException {
+        List<String> models = new ArrayList<>();
+        for (DataModelDesc modelDesc : getModels(projectName)) {
+            if (modelDesc.getAllTables().contains(tableName.toUpperCase())) {
+                models.add(modelDesc.getName());
+            }
+        }
+        return models;
+    }
+
     public boolean isTableInAnyModel(String tableName) {
         for (DataModelDesc modelDesc : getModels()) {
             if (modelDesc.getAllTables().contains(tableName.toUpperCase())) {

http://git-wip-us.apache.org/repos/asf/kylin/blob/ef44b7f6/server-base/src/main/java/org/apache/kylin/rest/controller/TableController.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/controller/TableController.java
b/server-base/src/main/java/org/apache/kylin/rest/controller/TableController.java
index 34cc57f..d9050c1 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/controller/TableController.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/controller/TableController.java
@@ -197,6 +197,9 @@ public class TableController extends BasicController {
             if (!modelService.isTableInModel(tableName, project)) {
                 cubeMgmtService.removeTableFromProject(tableName, project);
                 rtn = true;
+            }else{
+                List<String> models = modelService.getModelsUsingTable(tableName, project);
+                throw new InternalErrorException("Table is already in use by models "+models);
             }
         } catch (IOException e) {
             logger.error(e.getMessage(), e);

http://git-wip-us.apache.org/repos/asf/kylin/blob/ef44b7f6/server-base/src/main/java/org/apache/kylin/rest/service/ModelService.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/service/ModelService.java b/server-base/src/main/java/org/apache/kylin/rest/service/ModelService.java
index bfff619..2f8667c 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/service/ModelService.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/service/ModelService.java
@@ -132,4 +132,11 @@ public class ModelService extends BasicService {
         tableName = dbTableName[0] + "." + dbTableName[1];
         return getMetadataManager().isTableInModel(tableName, projectName);
     }
+
+    @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#desc, 'ADMINISTRATION')
or hasPermission(#desc, 'MANAGEMENT')")
+    public List<String> getModelsUsingTable(String tableName, String projectName) throws
IOException {
+        String[] dbTableName = HadoopUtil.parseHiveTableName(tableName);
+        tableName = dbTableName[0] + "." + dbTableName[1];
+        return getMetadataManager().getModelsUsingTable(tableName, projectName);
+    }
 }


Mime
View raw message