carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chenliang...@apache.org
Subject [1/2] incubator-carbondata git commit: Fixed drop table with dbname
Date Wed, 06 Jul 2016 06:37:49 GMT
Repository: incubator-carbondata
Updated Branches:
  refs/heads/master beb0c9fd8 -> e86568568


Fixed drop table with dbname

Fixed hdfs folder path issue which contains '-'

Reverted commented testcase code


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

Branch: refs/heads/master
Commit: b77695f136a98bc00ee15ea9138199fa01fca5e0
Parents: beb0c9f
Author: ravipesala <ravi.pesala@gmail.com>
Authored: Sun Jul 3 23:15:52 2016 +0530
Committer: chenliang613 <chenliang613@apache.org>
Committed: Wed Jul 6 12:05:52 2016 +0530

----------------------------------------------------------------------
 .../core/carbon/path/CarbonTablePath.java         | 18 +++++++++++++++---
 .../spark/sql/hive/CarbonMetastoreCatalog.scala   | 12 ++++++------
 .../apache/spark/sql/hive/CarbonStrategies.scala  | 13 +++++++++++--
 .../deleteTable/TestDeleteTableNewDDL.scala       | 13 +++++++++++++
 4 files changed, 45 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/b77695f1/core/src/main/java/org/carbondata/core/carbon/path/CarbonTablePath.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/core/carbon/path/CarbonTablePath.java b/core/src/main/java/org/carbondata/core/carbon/path/CarbonTablePath.java
index 2ac6817..dd02f49 100644
--- a/core/src/main/java/org/carbondata/core/carbon/path/CarbonTablePath.java
+++ b/core/src/main/java/org/carbondata/core/carbon/path/CarbonTablePath.java
@@ -306,7 +306,7 @@ public class CarbonTablePath extends Path {
      */
     public static String getUpdateTimeStamp(String carbonDataFileName) {
       // Get the file name from path
-      String fileName = new File(carbonDataFileName).getName();
+      String fileName = getFileName(carbonDataFileName);
       // + 1 for size of "-"
       int firstDashPos = fileName.indexOf("-");
       int secondDashPos = fileName.indexOf("-", firstDashPos + 1);
@@ -320,7 +320,7 @@ public class CarbonTablePath extends Path {
      */
     public static String getPartNo(String carbonDataFileName) {
       // Get the file name from path
-      String fileName = new File(carbonDataFileName).getName();
+      String fileName = getFileName(carbonDataFileName);
       // + 1 for size of "-"
       int startIndex = fileName.indexOf("-") + 1;
       int endIndex = fileName.indexOf("-", startIndex);
@@ -332,13 +332,25 @@ public class CarbonTablePath extends Path {
      */
     public static String getTaskNo(String carbonDataFileName) {
       // Get the file name from path
-      String fileName = new File(carbonDataFileName).getName();
+      String fileName = getFileName(carbonDataFileName);
       // + 1 for size of "-"
       int firstDashPos = fileName.indexOf("-");
       int startIndex = fileName.indexOf("-", firstDashPos + 1) + 1;
       int endIndex = fileName.indexOf("-", startIndex);
       return fileName.substring(startIndex, endIndex);
     }
+
+    /**
+     * Gets the file name from file path
+     */
+    private static String getFileName(String carbonDataFileName) {
+      int endIndex = carbonDataFileName.lastIndexOf(CarbonCommonConstants.FILE_SEPARATOR);
+      if (endIndex > -1) {
+        return carbonDataFileName.substring(endIndex + 1, carbonDataFileName.length());
+      } else {
+        return carbonDataFileName;
+      }
+    }
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/b77695f1/integration/spark/src/main/scala/org/apache/spark/sql/hive/CarbonMetastoreCatalog.scala
----------------------------------------------------------------------
diff --git a/integration/spark/src/main/scala/org/apache/spark/sql/hive/CarbonMetastoreCatalog.scala
b/integration/spark/src/main/scala/org/apache/spark/sql/hive/CarbonMetastoreCatalog.scala
index d84f554..259266a 100644
--- a/integration/spark/src/main/scala/org/apache/spark/sql/hive/CarbonMetastoreCatalog.scala
+++ b/integration/spark/src/main/scala/org/apache/spark/sql/hive/CarbonMetastoreCatalog.scala
@@ -498,6 +498,12 @@ class CarbonMetastoreCatalog(hiveContext: HiveContext, val storePath:
String,
       }
     }
 
+    metadata.cubesMeta -= metadata.cubesMeta.filter(
+      c => c.carbonTableIdentifier.getDatabaseName.equalsIgnoreCase(dbName) &&
+           c.carbonTableIdentifier.getTableName.equalsIgnoreCase(tableName))(0)
+    org.carbondata.core.carbon.metadata.CarbonMetadata.getInstance
+      .removeTable(dbName + "_" + tableName)
+
     try {
       sqlContext.sql(s"DROP TABLE $dbName.$tableName").collect()
     } catch {
@@ -505,12 +511,6 @@ class CarbonMetastoreCatalog(hiveContext: HiveContext, val storePath:
String,
         LOGGER.audit(
           s"Error While deleting the table $dbName.$tableName during drop Table" + e.getMessage)
     }
-
-    metadata.cubesMeta -= metadata.cubesMeta.filter(
-      c => c.carbonTableIdentifier.getDatabaseName.equalsIgnoreCase(dbName) &&
-           c.carbonTableIdentifier.getTableName.equalsIgnoreCase(tableName))(0)
-    org.carbondata.core.carbon.metadata.CarbonMetadata.getInstance
-      .removeTable(dbName + "_" + tableName)
     logInfo(s"Table $tableName of $dbName Database dropped syccessfully.")
     LOGGER.info("Table " + tableName + " of " + dbName + " Database dropped syccessfully.")
 

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/b77695f1/integration/spark/src/main/scala/org/apache/spark/sql/hive/CarbonStrategies.scala
----------------------------------------------------------------------
diff --git a/integration/spark/src/main/scala/org/apache/spark/sql/hive/CarbonStrategies.scala
b/integration/spark/src/main/scala/org/apache/spark/sql/hive/CarbonStrategies.scala
index 1de8908..756e088 100644
--- a/integration/spark/src/main/scala/org/apache/spark/sql/hive/CarbonStrategies.scala
+++ b/integration/spark/src/main/scala/org/apache/spark/sql/hive/CarbonStrategies.scala
@@ -233,8 +233,9 @@ class CarbonStrategies(sqlContext: SQLContext) extends QueryPlanner[SparkPlan]
{
         ExecutedCommand(ShowAllTablesDetail(schemaName, plan.output)) :: Nil
       case DropTable(tableName, ifNotExists)
         if CarbonEnv.getInstance(sqlContext).carbonCatalog
-            .tableExists(TableIdentifier(tableName.toLowerCase, None))(sqlContext) =>
-        ExecutedCommand(DropTableCommand(ifNotExists, None, tableName.toLowerCase)) :: Nil
+            .tableExists(toTableIdentifier(tableName.toLowerCase))(sqlContext) =>
+        val identifier = toTableIdentifier(tableName.toLowerCase)
+        ExecutedCommand(DropTableCommand(ifNotExists, identifier.database, identifier.table))
:: Nil
       case ShowAggregateTablesCommand(schemaName) =>
         ExecutedCommand(ShowAggregateTables(schemaName, plan.output)) :: Nil
       case ShowLoadsCommand(schemaName, cube, limit) =>
@@ -286,6 +287,14 @@ class CarbonStrategies(sqlContext: SQLContext) extends QueryPlanner[SparkPlan]
{
       case _ =>
         Nil
     }
+
+    def toTableIdentifier(name: String): TableIdentifier = {
+      val identifier = name.split("\\.")
+      identifier match {
+        case Array(tableName) => TableIdentifier(tableName, None)
+        case Array(dbName, tableName) => TableIdentifier(tableName, Some(dbName))
+      }
+    }
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/b77695f1/integration/spark/src/test/scala/org/carbondata/spark/testsuite/deleteTable/TestDeleteTableNewDDL.scala
----------------------------------------------------------------------
diff --git a/integration/spark/src/test/scala/org/carbondata/spark/testsuite/deleteTable/TestDeleteTableNewDDL.scala
b/integration/spark/src/test/scala/org/carbondata/spark/testsuite/deleteTable/TestDeleteTableNewDDL.scala
index aeac733..7b58308 100644
--- a/integration/spark/src/test/scala/org/carbondata/spark/testsuite/deleteTable/TestDeleteTableNewDDL.scala
+++ b/integration/spark/src/test/scala/org/carbondata/spark/testsuite/deleteTable/TestDeleteTableNewDDL.scala
@@ -74,6 +74,19 @@ class TestDeleteTableNewDDL extends QueryTest with BeforeAndAfterAll {
 
   }
 
+  test("drop table using dbName and table name") {
+    // create table
+    sql(
+      "CREATE table default.table3 (ID int, date String, country String, name " +
+      "String," +
+      "phonetype String, serialname String, salary int) stored by 'org.apache.carbondata.format'"
+
+      "TBLPROPERTIES('DICTIONARY_INCLUDE'='ID', 'DICTIONARY_INCLUDE'='salary')"
+    )
+    // table should drop wihout any error
+    sql("drop table default.table3")
+
+  }
+
 
   override def afterAll: Unit = {
 


Mime
View raw message