carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravipes...@apache.org
Subject [23/50] carbondata git commit: changed dbname to lowercase in rename table
Date Thu, 11 May 2017 13:53:13 GMT
changed dbname to lowercase in rename table


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

Branch: refs/heads/branch-1.1
Commit: f05f00cc8dd1bec67092e4e55fd5bf0034d1cd55
Parents: ce84e19
Author: kunal642 <kunal.kapoor@knoldus.in>
Authored: Mon May 8 19:49:36 2017 +0530
Committer: kunal642 <kunal.kapoor@knoldus.in>
Committed: Mon May 8 19:49:36 2017 +0530

----------------------------------------------------------------------
 .../apache/spark/sql/execution/command/DDLStrategy.scala    | 6 ++++--
 .../restructure/AlterTableValidationTestCase.scala          | 9 +++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/f05f00cc/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/DDLStrategy.scala
----------------------------------------------------------------------
diff --git a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/DDLStrategy.scala
b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/DDLStrategy.scala
index 8afadf0..3593b6d 100644
--- a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/DDLStrategy.scala
+++ b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/DDLStrategy.scala
@@ -39,11 +39,13 @@ class DDLStrategy(sparkSession: SparkSession) extends SparkStrategy {
         ExecutedCommandExec(LoadTable(identifier.database, identifier.table.toLowerCase,
path,
           Seq(), Map(), isOverwrite)) :: Nil
       case alter@AlterTableRenameCommand(oldTableIdentifier, newTableIdentifier, _) =>
+        val dbOption = oldTableIdentifier.database.map(_.toLowerCase)
+        val tableIdentifier = TableIdentifier(oldTableIdentifier.table.toLowerCase(), dbOption)
         val isCarbonTable = CarbonEnv.getInstance(sparkSession).carbonMetastore
-          .tableExists(oldTableIdentifier)(
+          .tableExists(tableIdentifier)(
             sparkSession)
         if (isCarbonTable) {
-          val renameModel = AlterTableRenameModel(oldTableIdentifier, newTableIdentifier)
+          val renameModel = AlterTableRenameModel(tableIdentifier, newTableIdentifier)
           ExecutedCommandExec(AlterTableRenameTable(renameModel)) :: Nil
         } else {
           ExecutedCommandExec(alter) :: Nil

http://git-wip-us.apache.org/repos/asf/carbondata/blob/f05f00cc/integration/spark2/src/test/scala/org/apache/spark/carbondata/restructure/AlterTableValidationTestCase.scala
----------------------------------------------------------------------
diff --git a/integration/spark2/src/test/scala/org/apache/spark/carbondata/restructure/AlterTableValidationTestCase.scala
b/integration/spark2/src/test/scala/org/apache/spark/carbondata/restructure/AlterTableValidationTestCase.scala
index 90a88f6..f184b4f 100644
--- a/integration/spark2/src/test/scala/org/apache/spark/carbondata/restructure/AlterTableValidationTestCase.scala
+++ b/integration/spark2/src/test/scala/org/apache/spark/carbondata/restructure/AlterTableValidationTestCase.scala
@@ -416,6 +416,14 @@ class AlterTableValidationTestCase extends QueryTest with BeforeAndAfterAll
{
       .exists())
   }
 
+  test("table rename with dbname in Camel Case") {
+    sql("drop table if exists uniqdata")
+    sql("""CREATE TABLE uniqdata (CUST_ID int,CUST_NAME String) STORED BY 'org.apache.carbondata.format'""")
+    sql("""insert into table uniqdata values(1,"hello")""")
+    sql("alter table Default.uniqdata rename to uniqdata1")
+    checkAnswer(sql("select * from Default.uniqdata1"), Row(1,"hello"))
+  }
+
   override def afterAll {
     sql("DROP TABLE IF EXISTS restructure")
     sql("DROP TABLE IF EXISTS restructure_new")
@@ -423,5 +431,6 @@ class AlterTableValidationTestCase extends QueryTest with BeforeAndAfterAll
{
     sql("DROP TABLE IF EXISTS restructure_bad")
     sql("DROP TABLE IF EXISTS restructure_badnew")
     sql("DROP TABLE IF EXISTS lock_rename")
+    sql("drop table if exists uniqdata")
   }
 }


Mime
View raw message