csun5285 commented on code in PR #22159:
URL: https://github.com/apache/doris/pull/22159#discussion_r1279023738


##########
regression-test/suites/compaction/test_table_level_compaction_policy.groovy:
##########
@@ -0,0 +1,131 @@
+// 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.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+suite("test_table_level_compaction_policy") {
+    def tableName = "test_table_level_compaction_policy"
+    sql """ DROP TABLE IF EXISTS ${tableName} """
+
+    sql """
+            CREATE TABLE ${tableName} (
+                    `c_custkey` int(11) NOT NULL COMMENT "",
+                    `c_name` varchar(26) NOT NULL COMMENT "",
+                    `c_address` varchar(41) NOT NULL COMMENT "",
+                    `c_city` varchar(11) NOT NULL COMMENT ""
+            )
+            DUPLICATE KEY (`c_custkey`)
+            DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 1
+            PROPERTIES (
+                    "replication_num" = "1",
+                    "compaction_policy" = "time_series",
+                    "time_series_compaction_goal_size_mbytes" = "1024", 
+                    "time_series_compaction_file_count_threshold" = "5000",
+                    "time_series_compaction_time_threshold_seconds" = "86400"
+             );
+        """
+    result = sql """show create table ${tableName}"""
+    logger.info("${result}")
+    assertTrue(result.toString().containsIgnoreCase('"compaction_policy" = 
"time_series"'))
+    
assertTrue(result.toString().containsIgnoreCase('"time_series_compaction_goal_size_mbytes"
 = "1024"'))
+    
assertTrue(result.toString().containsIgnoreCase('"time_series_compaction_file_count_threshold"
 = "5000"'))
+    
assertTrue(result.toString().containsIgnoreCase('"time_series_compaction_time_threshold_seconds"
 = "86400"'))
+
+    sql """
+        alter table ${tableName} set 
("time_series_compaction_goal_size_mbytes" = "2048")
+        """
+
+    result = sql """show create table ${tableName}"""
+    logger.info("${result}")
+    
assertTrue(result.toString().containsIgnoreCase('"time_series_compaction_goal_size_mbytes"
 = "2048"'))
+
+    sql """
+        alter table ${tableName} set 
("time_series_compaction_file_count_threshold" = "6000")
+        """
+
+    result = sql """show create table ${tableName}"""
+    logger.info("${result}")
+    
assertTrue(result.toString().containsIgnoreCase('"time_series_compaction_file_count_threshold"
 = "6000"'))
+
+     sql """
+        alter table ${tableName} set 
("time_series_compaction_time_threshold_seconds" = "3000")
+        """
+
+    result = sql """show create table ${tableName}"""
+    logger.info("${result}")
+    
assertTrue(result.toString().containsIgnoreCase('"time_series_compaction_time_threshold_seconds"
 = "3000"'))
+
+    sql """ DROP TABLE IF EXISTS ${tableName} """
+
+    test {
+        sql """
+            CREATE TABLE ${tableName} (
+                    `c_custkey` int(11) NOT NULL COMMENT "",
+                    `c_name` varchar(26) NOT NULL COMMENT "",
+                    `c_address` varchar(41) NOT NULL COMMENT "",
+                    `c_city` varchar(11) NOT NULL COMMENT ""
+            )
+            DUPLICATE KEY (`c_custkey`)
+            DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 1
+            PROPERTIES (
+                    "replication_num" = "1",
+                    "compaction_policy" = "ok"
+             );
+        """
+        exception "compaction_policy must be time_series or size_based"
+    }
+
+    test {
+        sql """
+            CREATE TABLE ${tableName} (
+                    `c_custkey` int(11) NOT NULL COMMENT "",
+                    `c_name` varchar(26) NOT NULL COMMENT "",
+                    `c_address` varchar(41) NOT NULL COMMENT "",
+                    `c_city` varchar(11) NOT NULL COMMENT ""
+            )
+            DUPLICATE KEY (`c_custkey`)
+            DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 1
+            PROPERTIES (
+                    "replication_num" = "1",
+                    "time_series_compaction_goal_size_mbytes" = "1024"
+             );
+        """
+        exception "only time series compaction policy support for time series 
config"
+    }
+
+    test {
+        sql """
+            CREATE TABLE ${tableName} (
+                    `c_custkey` int(11) NOT NULL COMMENT "",
+                    `c_name` varchar(26) NOT NULL COMMENT "",
+                    `c_address` varchar(41) NOT NULL COMMENT "",
+                    `c_city` varchar(11) NOT NULL COMMENT ""
+            )
+            DUPLICATE KEY (`c_custkey`)
+            DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 1
+            PROPERTIES (
+                    "replication_num" = "1"
+             );
+        """
+
+        sql """
+            alter table  ${tableName} set ("compaction_policy" = "ok")
+            """
+        exception "Table compaction policy only support for time_series or 
size_based"
+    }
+    sql """ DROP TABLE IF EXISTS ${tableName} """
+}

Review Comment:
   done



-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to