qiuchenjian commented on a change in pull request #3094: [CARBONDATA-3264] Added SORT_SCOPE in ALTER TABLE SET
URL: https://github.com/apache/carbondata/pull/3094#discussion_r249682110 ########## File path: integration/spark-common-cluster-test/src/test/scala/org/apache/carbondata/cluster/sdv/generated/AlterTableTestCase.scala ########## @@ -1016,6 +1016,62 @@ class AlterTableTestCase extends QueryTest with BeforeAndAfterAll { } } + + test("AlterTable Change Sort Scope 1") { + sql("DROP TABLE IF EXISTS t1") + sql(s"CREATE TABLE t1(age int, name string) STORED BY 'carbondata' TBLPROPERTIES" + + s"('sort_scope'='local_sort', 'sort_columns'='age')") + sql("ALTER TABLE t1 SET TBLPROPERTIES('sort_scope'='batch_sort')") + + var sort_scope: String = "" + sql("DESCRIBE FORMATTED t1").collect().foreach(row => { + if (row.getAs[String]("col_name").equalsIgnoreCase("sort scope")) { + sort_scope = row.getAs[String]("data_type") + } + }) + assert(sort_scope.equalsIgnoreCase("batch_sort")) + sql("DROP TABLE t1") + } + + test("AlterTable Change Sort Scope 2") { + sql("DROP TABLE IF EXISTS t1") + sql(s"CREATE TABLE t1(age int, name string) STORED BY 'carbondata' TBLPROPERTIES" + + s"('sort_columns'='')") + sql("ALTER TABLE t1 SET TBLPROPERTIES('sort_scope'='local_sort')") + + var sort_scope: String = "" + sql("DESCRIBE FORMATTED t1").collect().foreach(row => { + if (row.getAs[String]("col_name").equalsIgnoreCase("sort scope")) { + sort_scope = row.getAs[String]("data_type") + } + }) + + // Even if we change the SORT_SCOPE to NO_SORT + // the SORT_SCOPE should remain to NO_SORT + // because SORT_COLUMNS does not contain anything. + assert(sort_scope.equalsIgnoreCase("no_sort")) + sql("DROP TABLE t1") + } + + test("AlterTable Change Sort Scope 3") { + sql("DROP TABLE IF EXISTS t1") + sql(s"CREATE TABLE t1(age int, name string) STORED BY 'carbondata' TBLPROPERTIES" + + s"('sort_scope'='local_sort', 'sort_columns'='age')") + sql("ALTER TABLE t1 UNSET TBLPROPERTIES('sort_scope')") + + var sort_scope: String = "" + sql("DESCRIBE FORMATTED t1").collect().foreach(row => { + if (row.getAs[String]("col_name").equalsIgnoreCase("sort scope")) { + sort_scope = row.getAs[String]("data_type") + } + }) + + // Unsetting the SORT_SCOPE should change the SORT_SCOPE to NO_SORT + assert(sort_scope.equalsIgnoreCase("no_sort")) Review comment: better to use CarbonCommonConstants.LOAD_SORT_SCOPE_DEFAULT, because default value may change in the future ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on 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 |