carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravipes...@apache.org
Subject [1/2] incubator-carbondata git commit: drop database cascade should be restricted
Date Tue, 30 Aug 2016 10:53:54 GMT
Repository: incubator-carbondata
Updated Branches:
  refs/heads/master bbc4ffabd -> 8567ec600


drop database cascade should be restricted

Fixed Review comments


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

Branch: refs/heads/master
Commit: b26e3b28b1f24d285a494784f2290f649d92d1bc
Parents: bbc4ffa
Author: nareshpr <prnaresh.naresh@gmail.com>
Authored: Mon Aug 29 15:25:40 2016 +0530
Committer: ravipesala <ravi.pesala@gmail.com>
Committed: Tue Aug 30 16:22:24 2016 +0530

----------------------------------------------------------------------
 .../scala/org/apache/spark/sql/CarbonSqlParser.scala  | 10 +++++++++-
 .../testsuite/deleteTable/TestDeleteTableNewDDL.scala | 14 ++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/b26e3b28/integration/spark/src/main/scala/org/apache/spark/sql/CarbonSqlParser.scala
----------------------------------------------------------------------
diff --git a/integration/spark/src/main/scala/org/apache/spark/sql/CarbonSqlParser.scala b/integration/spark/src/main/scala/org/apache/spark/sql/CarbonSqlParser.scala
index eeced79..318c78a 100644
--- a/integration/spark/src/main/scala/org/apache/spark/sql/CarbonSqlParser.scala
+++ b/integration/spark/src/main/scala/org/apache/spark/sql/CarbonSqlParser.scala
@@ -59,6 +59,7 @@ class CarbonSqlParser()
   protected val BEFORE = carbonKeyWord("BEFORE")
   protected val BY = carbonKeyWord("BY")
   protected val CARDINALITY = carbonKeyWord("CARDINALITY")
+  protected val CASCADE = carbonKeyWord("CASCADE")
   protected val CLASS = carbonKeyWord("CLASS")
   protected val CLEAN = carbonKeyWord("CLEAN")
   protected val COLS = carbonKeyWord("COLS")
@@ -67,6 +68,7 @@ class CarbonSqlParser()
   protected val CUBE = carbonKeyWord("CUBE")
   protected val CUBES = carbonKeyWord("CUBES")
   protected val DATA = carbonKeyWord("DATA")
+  protected val DATABASE = carbonKeyWord("DATABASE")
   protected val DATABASES = carbonKeyWord("DATABASES")
   protected val DELETE = carbonKeyWord("DELETE")
   protected val DELIMITER = carbonKeyWord("DELIMITER")
@@ -109,6 +111,7 @@ class CarbonSqlParser()
   protected val PARTITIONER = carbonKeyWord("PARTITIONER")
   protected val QUOTECHAR = carbonKeyWord("QUOTECHAR")
   protected val RELATION = carbonKeyWord("RELATION")
+  protected val SCHEMA = carbonKeyWord("SCHEMA")
   protected val SCHEMAS = carbonKeyWord("SCHEMAS")
   protected val SHOW = carbonKeyWord("SHOW")
   protected val TABLES = carbonKeyWord("TABLES")
@@ -202,7 +205,7 @@ class CarbonSqlParser()
   override protected lazy val start: Parser[LogicalPlan] = explainPlan | startCommand
 
   protected lazy val startCommand: Parser[LogicalPlan] =
-    loadManagement | describeTable | showLoads | alterTable | createTable
+    dropDatabaseCascade | loadManagement | describeTable | showLoads | alterTable | createTable
 
   protected lazy val loadManagement: Parser[LogicalPlan] = deleteLoadsByID | deleteLoadsByLoadDate
|
     cleanFiles | loadDataNew
@@ -1342,4 +1345,9 @@ class CarbonSqlParser()
       }
     }
 
+  protected lazy val dropDatabaseCascade: Parser[LogicalPlan] =
+    DROP ~> (DATABASE|SCHEMA) ~> opt(IF ~> EXISTS) ~> ident ~> CASCADE <~
opt(";") ^^ {
+      case cascade => throw new MalformedCarbonCommandException(
+          "Unsupported cascade operation in drop database/schema command")
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/b26e3b28/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/deleteTable/TestDeleteTableNewDDL.scala
----------------------------------------------------------------------
diff --git a/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/deleteTable/TestDeleteTableNewDDL.scala
b/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/deleteTable/TestDeleteTableNewDDL.scala
index 3dd5b25..5aa8596 100644
--- a/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/deleteTable/TestDeleteTableNewDDL.scala
+++ b/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/deleteTable/TestDeleteTableNewDDL.scala
@@ -18,6 +18,7 @@
  */
 package org.apache.carbondata.spark.testsuite.deleteTable
 
+import org.apache.carbondata.spark.exception.MalformedCarbonCommandException
 import org.apache.spark.sql.common.util.CarbonHiveContext._
 import org.apache.spark.sql.common.util.QueryTest
 import org.scalatest.BeforeAndAfterAll
@@ -45,6 +46,19 @@ class TestDeleteTableNewDDL extends QueryTest with BeforeAndAfterAll {
     sql("drop table table1")
 
   }
+  
+  test("test drop database cascade command") {
+    sql("create database testdb")
+    try {
+      sql("drop database testdb cascade")
+      assert(false)
+    } catch {
+      case e : MalformedCarbonCommandException => {
+        assert(e.getMessage.equals("Unsupported cascade operation in drop database/schema
command"))
+      }
+    }
+    sql("drop database testdb")
+  }
 
   // deletion case with if exists
   test("drop table if exists Test with new DDL") {


Mime
View raw message