You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ja...@apache.org on 2017/12/24 13:26:33 UTC
[37/50] [abbrv] carbondata git commit: [CARBONDATA-1618] SDV test
cases for Table comment support for alter table
[CARBONDATA-1618] SDV test cases for Table comment support for alter table
This closes #1612
Project: http://git-wip-us.apache.org/repos/asf/carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/carbondata/commit/a8cbacf3
Tree: http://git-wip-us.apache.org/repos/asf/carbondata/tree/a8cbacf3
Diff: http://git-wip-us.apache.org/repos/asf/carbondata/diff/a8cbacf3
Branch: refs/heads/fgdatamap
Commit: a8cbacf3e923600d509fc080ebef6a4eaf992c3e
Parents: e2360c7
Author: Pawan Malwal <pm...@gmail.com>
Authored: Tue Dec 5 12:55:46 2017 +0530
Committer: ravipesala <ra...@gmail.com>
Committed: Fri Dec 22 09:58:27 2017 +0530
----------------------------------------------------------------------
.../TableCommentAlterTableTestCase.scala | 146 +++++++++++++++++++
.../cluster/sdv/suite/SDVSuites.scala | 4 +-
2 files changed, 149 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/carbondata/blob/a8cbacf3/integration/spark-common-cluster-test/src/test/scala/org/apache/carbondata/cluster/sdv/generated/TableCommentAlterTableTestCase.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common-cluster-test/src/test/scala/org/apache/carbondata/cluster/sdv/generated/TableCommentAlterTableTestCase.scala b/integration/spark-common-cluster-test/src/test/scala/org/apache/carbondata/cluster/sdv/generated/TableCommentAlterTableTestCase.scala
new file mode 100644
index 0000000..8bd53ae
--- /dev/null
+++ b/integration/spark-common-cluster-test/src/test/scala/org/apache/carbondata/cluster/sdv/generated/TableCommentAlterTableTestCase.scala
@@ -0,0 +1,146 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.carbondata.cluster.sdv.generated
+
+import org.apache.spark.sql.{AnalysisException, Row}
+import org.apache.spark.sql.common.util._
+import org.scalatest.BeforeAndAfterAll
+
+/**
+ * Test Class for AlterTableTestCase to verify all scenerios
+ */
+
+class TableCommentAlterTableTestCase extends QueryTest with BeforeAndAfterAll {
+
+
+ //Check create table with table comment
+ test("TableCommentAlterTable_001_01", Include) {
+ sql(s"""drop table if exists table_comment""").collect
+ sql(s""" create table table_comment(id int, name string) comment "This is table comment" STORED BY 'carbondata'""").collect
+ val result = sql("describe formatted table_comment")
+ checkExistence(result, true, "Comment")
+ checkExistence(result, true, "This is table comment")
+ }
+
+ //Check create table with comment as numeric/alphanumeric/special symbols
+ test("TableCommentAlterTable_001_02", Include) {
+ sql(s"""drop table if exists table_comment_special""").collect
+ sql(s"""create table table_comment_special(id int, name string) comment "3432432 @This $$$$ is table comment #$$%^&*@# 34234" STORED BY 'carbondata'""").collect
+ val result = sql("describe formatted table_comment_special")
+ checkExistence(result, true, "Comment")
+ checkExistence(result, true, "3432432 @This $$ is table comment #$%^&*@# 34234")
+ }
+
+ //Check create table with comment as blank
+ test("TableCommentAlterTable_001_03", Include) {
+ sql(s"""drop table if exists table_comment_alphabets""").collect
+ sql(s"""create table table_comment_alphabets(id int, name string) comment "" STORED BY 'carbondata'""").collect
+ val result = sql("describe formatted table_comment")
+ checkExistence(result, true, "Comment")
+ }
+
+ //Check create table with comment as high values
+ test("TableCommentAlterTable_001_04", Include) {
+ sql(s"""drop table if exists table_comment_high""").collect
+ sql(s"""create table table_comment_high(id int, name string) comment "This is table comment jgfhdsjgfhsjdgjfsdgfbcfgr763 23x4bt23n8z30bt20t49ct4cb3g93t53945ctbugebgec4c3trbcu4grehrvsgyabrgyuwarcnrwbrcwe rwergrburygwae rwaeuigrwawewrcargw7aer wr766tznzYQEqoie weqeqewqeqweqweqweewqeqwe" STORED BY 'carbondata'""").collect
+ val result = sql("describe formatted table_comment_high")
+ checkExistence(result, true, "Comment")
+ checkExistence(result, true, "This is table comment jgfhdsjgfhsjdgjfsdgfbcfgr763 23x4bt23n8z30bt20t49ct4cb3g93t53945ctbugebgec4c3trbcu4grehrvsgyabrgyuwarcnrwbrcwe rwergrburygwae rwaeuigrwawewrcargw7aer wr766tznzYQEqoie weqeqewqeqweqweqweewqeqwe")
+ }
+
+ //Check create table with comment in the table properties
+ test("TableCommentAlterTable_001_05", Include) {
+ sql(s"""drop table if exists table_comment_asprop""").collect
+ sql(s"""create table table_comment_asprop (imei string,num bigint,game double,date timestamp,Profit decimal(3,2)) STORED BY 'carbondata' TBLPROPERTIES('comment'='This is table comment..!!')""").collect
+ val result = sql("describe formatted table_comment")
+ checkExistence(result, true, "Comment")
+ checkExistence(result, false, "This is table comment..!!")
+ }
+
+ //Check create table with comment after stored by clause
+ test("TableCommentAlterTable_001_06", Include) {
+ intercept[AnalysisException] {
+ sql("create table table_comment_afterstoredby (id int, name string) STORED BY 'carbondata' comment 'This is table comment'")
+ }
+ }
+
+ //Check the comment by "describe formatted"
+ test("TableCommentAlterTable_001_07", Include) {
+ sql(s"""drop table if exists table_comment""").collect
+ sql(s""" create table table_comment(id int, name string) comment "This is table comment" STORED BY 'carbondata'""").collect
+ val result = sql("describe formatted table_comment")
+ checkExistence(result, true, "Comment")
+ checkExistence(result, true, "This is table comment")
+ }
+
+ //Check SET Command by using alter command
+ test("TableCommentAlterTable_001_08", Include) {
+ sql(s"""drop table if exists table_comment_set""").collect
+ sql(s"""create table table_comment_set (id int, name string) STORED BY 'carbondata'""").collect
+ sql(s"""alter table table_comment_set SET TBLPROPERTIES ('comment'='This table comment is SET by alter table set')""").collect
+ val result = sql("describe formatted table_comment_set")
+ checkExistence(result, true, "Comment")
+ checkExistence(result, true, "This table comment is SET by alter table set")
+ }
+
+ //Check UNSET Command by using alter command
+ test("TableCommentAlterTable_001_09", Include) {
+ sql(s"""drop table if exists table_comment_unset""").collect
+ sql(s"""create table table_comment_unset(id int, name string) comment "This is table comment" STORED BY 'carbondata'""").collect
+ val result1 = sql("describe formatted table_comment_unset")
+ checkExistence(result1, true, "Comment")
+ checkExistence(result1, true, "This is table comment")
+
+ sql(s"""alter table table_comment_unset UNSET TBLPROPERTIES IF EXISTS ('comment')""").collect
+ val result2 = sql("describe formatted table_comment_unset")
+ checkExistence(result2, true, "Comment")
+ checkExistence(result2, false, "This is table comment")
+ }
+
+ //Check RENAME by using alter command
+ test("TableCommentAlterTable_001_10", Include) {
+ sql(s"""drop table if exists table_comment_rename1""").collect
+ sql(s"""create table table_comment_rename1 (id int, name string) STORED BY 'carbondata'""").collect
+ sql(s"""alter table table_comment_rename1 rename to table_comment_rename2""").collect
+ val result = sql("describe formatted table_comment_rename2")
+ checkExistence(result, true, "Comment")
+ checkExistence(result, true, "table_comment")
+ }
+
+ //Check ADD Columns by using alter command
+ test("TableCommentAlterTable_001_11", Include) {
+ sql(s"""drop table if exists table_add_column """).collect
+ sql(s"""create table table_add_column (name string, country string, upd_time timestamp) stored by 'carbondata'""").collect
+ sql(s"""alter table table_add_column add columns (id bigint)""").collect
+ val result = sql("describe table_add_column ")
+ checkExistence(result, true, "id")
+ checkExistence(result, true, "bigint")
+ }
+
+ //Check CHANGE DATA TYPE by using alter command
+ test("TableCommentAlterTable_001_12", Include) {
+ sql(s"""drop table if exists table_change_datatype""").collect
+ sql(s"""create table table_change_datatype (name string, id decimal(3,2),country string) stored by 'carbondata'""").collect
+ sql(s"""alter table table_change_datatype change id id decimal(10,4)""").collect
+ val result = sql("describe formatted table_change_datatype")
+ checkExistence(result, true, "Comment")
+ checkExistence(result, true, "decimal(10,4)")
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/carbondata/blob/a8cbacf3/integration/spark-common-cluster-test/src/test/scala/org/apache/carbondata/cluster/sdv/suite/SDVSuites.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common-cluster-test/src/test/scala/org/apache/carbondata/cluster/sdv/suite/SDVSuites.scala b/integration/spark-common-cluster-test/src/test/scala/org/apache/carbondata/cluster/sdv/suite/SDVSuites.scala
index 440d333..b968ae6 100644
--- a/integration/spark-common-cluster-test/src/test/scala/org/apache/carbondata/cluster/sdv/suite/SDVSuites.scala
+++ b/integration/spark-common-cluster-test/src/test/scala/org/apache/carbondata/cluster/sdv/suite/SDVSuites.scala
@@ -52,6 +52,7 @@ class SDVSuites extends Suites with BeforeAndAfterAll {
new ShowLoadsTestCase ::
new SinglepassTestCase ::
new SortColumnTestCase ::
+ new TableCommentAlterTableTestCase ::
new TimestamptypesTestCase ::
new V3offheapvectorTestCase ::
new Vector1TestCase ::
@@ -135,7 +136,8 @@ class SDVSuites3 extends Suites with BeforeAndAfterAll {
new QueriesSparkBlockDistTestCase ::
new DataLoadingV3TestCase ::
new QueriesIncludeDictionaryTestCase ::
- new TestRegisterCarbonTable :: Nil
+ new TestRegisterCarbonTable ::
+ new TableCommentAlterTableTestCase :: Nil
override val nestedSuites = suites.toIndexedSeq