zzcclp commented on a change in pull request #3504: [WIP] [CARBONDATA-3614] Support Alter table properties set/unset for longstring columns
URL: https://github.com/apache/carbondata/pull/3504#discussion_r355910652 ########## File path: integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/longstring/VarcharDataTypesBasicTestCase.scala ########## @@ -191,6 +192,82 @@ class VarcharDataTypesBasicTestCase extends QueryTest with BeforeAndAfterEach wi assert(exceptionCaught.getMessage.contains("both in no_inverted_index and long_string_columns")) } + test("test alter table properties for long string columns") { + sql("drop table if exists testlongstring") + sql( + s""" + | CREATE TABLE if not exists testlongstring(id INT, name STRING, description STRING + | ) STORED BY 'carbondata' + |""".stripMargin) + sql("insert into testlongstring select 1, 'ab', 'cool'") + // describe formatted should not have long_string_columns + checkExistence(sql("describe formatted testlongstring"), false, "long_string_columns") + //Alter table add table property of long string columns + sql("ALTER TABLE testlongstring SET TBLPROPERTIES('long_String_columns'='name,description')") + sql(s""" insert into testlongstring select 1, 'ab1', '$longChar'""") + checkAnswer(sql("select * from testlongstring"), Seq(Row(1, "ab", "cool"), Row(1, "ab1", longChar))) + // describe formatted should have long_string_columns + checkExistence(sql("describe formatted testlongstring"), true, "LONG_STRING_COLUMNS") + //insert without without local dictionary + sql("ALTER TABLE testlongstring SET TBLPROPERTIES('local_dictionary_enable'='false')") + sql(s""" insert into testlongstring select 1, 'abc', '$longChar'""") + checkAnswer(sql("select * from testlongstring"), + Seq(Row(1, "ab", "cool"), Row(1, "ab1", longChar), Row(1, "abc", longChar))) + // Unset the long_String_columns + sql("ALTER TABLE testlongstring UNSET TBLPROPERTIES('long_string_columns')") + // describe formatted should not have long_string_columns + checkExistence(sql("describe formatted testlongstring"), false, "long_string_columns") + // query should pass + checkAnswer(sql("select * from testlongstring"), + Seq(Row(1, "ab", "cool"), Row(1, "ab1", longChar), Row(1, "abc", longChar))) + // insert long string should fail as unset is done + val e = intercept[Exception] { + sql(s""" insert into testlongstring select 1, 'abc', '$longChar'""") + } + assert(e.getMessage.contains("Dataload failed, String length cannot exceed 32000 characters")) + sql("ALTER TABLE testlongstring SET TBLPROPERTIES('long_String_columns'='description')") + sql(s""" insert into testlongstring select 1, 'ab1', '$longChar'""") + sql("drop table if exists testlongstring") + } + + test("test alter table properties for long string columns") { Review comment: please remove this duplicated test case. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] With regards, Apache Git Services |
Free forum by Nabble | Edit this page |