This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new d0eaf95977f [cases](regression-test) Add alter table properties and 
alter/rename view test (#25971)
d0eaf95977f is described below

commit d0eaf95977f24a7405275b6163242c895ba182b2
Author: walter <[email protected]>
AuthorDate: Fri Oct 27 10:27:06 2023 +0800

    [cases](regression-test) Add alter table properties and alter/rename view 
test (#25971)
---
 regression-test/data/ddl_p0/test_alter_view.out    |  11 +++
 .../data/schema_change_p0/test_rename_rollup.out   | Bin 0 -> 1364 bytes
 .../alter_p2/test_alter_table_property.groovy      |  69 ++++++++++++++++
 .../suites/ddl_p0/test_alter_view.groovy           |  63 +++++++++++++++
 .../schema_change_p0/test_rename_rollup.groovy     |  88 +++++++++++++++++++++
 5 files changed, 231 insertions(+)

diff --git a/regression-test/data/ddl_p0/test_alter_view.out 
b/regression-test/data/ddl_p0/test_alter_view.out
new file mode 100644
index 00000000000..98494a65d76
--- /dev/null
+++ b/regression-test/data/ddl_p0/test_alter_view.out
@@ -0,0 +1,11 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+1      1
+1      5
+2      1
+2      10
+
+-- !select --
+1      60
+2      70
+
diff --git a/regression-test/data/schema_change_p0/test_rename_rollup.out 
b/regression-test/data/schema_change_p0/test_rename_rollup.out
new file mode 100644
index 00000000000..789964e9277
Binary files /dev/null and 
b/regression-test/data/schema_change_p0/test_rename_rollup.out differ
diff --git a/regression-test/suites/alter_p2/test_alter_table_property.groovy 
b/regression-test/suites/alter_p2/test_alter_table_property.groovy
new file mode 100644
index 00000000000..474a7737d2f
--- /dev/null
+++ b/regression-test/suites/alter_p2/test_alter_table_property.groovy
@@ -0,0 +1,69 @@
+// 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.
+
+suite ("test_alter_table_property") {
+    String tableName = "test_alter_table_property_table"
+    sql "DROP TABLE IF EXISTS ${tableName}"
+    sql """
+        CREATE TABLE IF NOT EXISTS ${tableName}
+        (
+            id LARGEINT NOT NULL,
+            value LARGEINT SUM DEFAULT "0"
+        )
+        AGGREGATE KEY(`id`)
+        PARTITION BY RANGE(`id`)
+        (
+            PARTITION p1 VALUES LESS THAN ("100")
+        )
+        DISTRIBUTED BY HASH(`id`) BUCKETS 1
+        PROPERTIES
+        (
+            "replication_allocation" = "tag.location.default: 1"
+        )
+        """
+    sql "INSERT INTO ${tableName} VALUES (50, 100)"
+
+    def queryReplicaCount = { partitionName ->
+        def result = sql "ADMIN SHOW REPLICA DISTRIBUTION FROM ${tableName} 
PARTITION ${partitionName}"
+        int sum = 0
+        for (row in result) {
+            sum += row[1].toInteger()
+        }
+        sum
+    }
+
+    assertEquals(1, queryReplicaCount("p1"))
+
+    sql """ ALTER TABLE ${tableName} ADD PARTITION p2 VALUES LESS THAN ("200") 
"""
+    assertEquals(1, queryReplicaCount("p2"))
+
+    sql """ ALTER TABLE ${tableName} SET ( "default.replication_allocation" = 
"tag.location.default: 2" ) """
+    sql """ ALTER TABLE ${tableName} ADD PARTITION p3 VALUES LESS THAN ("300") 
"""
+    assertEquals(2, queryReplicaCount("p3"))
+
+    sql """ ALTER TABLE ${tableName} MODIFY PARTITION p1 SET ( 
"replication_allocation" = "tag.location.default: 2" ) """
+    for (i = 0; i < 300; i++) {
+        if (queryReplicaCount("p1") != 2) {
+            Thread.sleep(3000)
+        }
+    }
+    assertEquals(2, queryReplicaCount("p1"))
+    assertEquals(1, queryReplicaCount("p2"))
+
+    sql "DROP TABLE ${tableName}"
+}
+
diff --git a/regression-test/suites/ddl_p0/test_alter_view.groovy 
b/regression-test/suites/ddl_p0/test_alter_view.groovy
new file mode 100644
index 00000000000..c921a416284
--- /dev/null
+++ b/regression-test/suites/ddl_p0/test_alter_view.groovy
@@ -0,0 +1,63 @@
+// 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.
+
+suite("test_alter_view") {
+    String tableName = "test_alter_view_table";
+    String viewName = "test_alter_view_view";
+    sql " DROP TABLE IF EXISTS ${tableName}"
+    sql """
+        CREATE TABLE IF NOT EXISTS ${tableName}
+        (
+            c1 BIGINT NOT NULL,
+            c2 BIGINT NOT NULL,
+            c3 BIGINT NOT NULL
+        )
+        UNIQUE KEY (`c1`, `c2`)
+        DISTRIBUTED BY HASH(`c1`) BUCKETS 1
+        PROPERTIES
+        (
+            "replication_num" = "1"
+        )
+        """
+    sql """
+        CREATE VIEW IF NOT EXISTS ${viewName} (k1, k2)
+        AS
+        SELECT c1 as k1, c2 as k2 FROM ${tableName}
+        """
+
+    sql """
+        INSERT INTO ${tableName} VALUES
+        (1, 1, 10),
+        (1, 5, 50),
+        (2, 1, 20),
+        (2, 10, 50)
+        """
+
+    qt_select " SELECT * FROM ${viewName} "
+
+    sql """
+        ALTER VIEW ${viewName} (k1, k2)
+        AS
+        SELECT c1 as k1, sum(c3) as k2 FROM ${tableName} GROUP BY c1
+    """
+
+    qt_select " SELECT * FROM ${viewName} "
+
+    sql "DROP VIEW ${viewName}"
+    sql "DROP TABLE ${tableName}"
+}
+
diff --git a/regression-test/suites/schema_change_p0/test_rename_rollup.groovy 
b/regression-test/suites/schema_change_p0/test_rename_rollup.groovy
new file mode 100644
index 00000000000..fa097939c7e
--- /dev/null
+++ b/regression-test/suites/schema_change_p0/test_rename_rollup.groovy
@@ -0,0 +1,88 @@
+// 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.
+
+suite ("test_rename_rollup") {
+    def tableName = "rename_rollup_test"
+    def getRollupJobState = { tbName ->
+         def jobStateResult = sql """  SHOW ALTER TABLE ROLLUP WHERE 
TableName='${tbName}' ORDER BY CreateTime DESC LIMIT 1 """
+         return jobStateResult[0][8]
+    }
+    sql """ DROP TABLE IF EXISTS ${tableName} """
+    sql """
+            CREATE TABLE IF NOT EXISTS ${tableName} (
+                `user_id` LARGEINT NOT NULL COMMENT "用户id",
+                `date` DATE NOT NULL COMMENT "数据灌入日期时间",
+                `city` VARCHAR(20) COMMENT "用户所在城市",
+                `age` SMALLINT COMMENT "用户年龄",
+                `sex` TINYINT COMMENT "用户性别",
+                `cost` BIGINT SUM DEFAULT "0" COMMENT "用户总消费",
+                `max_dwell_time` INT MAX DEFAULT "0" COMMENT "用户最大停留时间",
+                `min_dwell_time` INT MIN DEFAULT "99999" COMMENT "用户最小停留时间",
+                `hll_col` HLL HLL_UNION NOT NULL COMMENT "HLL列",
+                `bitmap_col` Bitmap BITMAP_UNION NOT NULL COMMENT "bitmap列")
+            AGGREGATE KEY(`user_id`, `date`, `city`, `age`, `sex`) DISTRIBUTED 
BY HASH(`user_id`)
+            BUCKETS 8
+            PROPERTIES ( "replication_num" = "1", "light_schema_change" = 
"true" );
+        """
+    qt_desc """ desc ${tableName} """
+
+    def resRoll = "null"
+    def rollupName = "rollup_cost"
+    sql "ALTER TABLE ${tableName} ADD ROLLUP ${rollupName}(`user_id`, `cost`);"
+    int max_try_time = 3000
+    while (max_try_time--){
+        String result = getRollupJobState(tableName)
+        if (result == "FINISHED") {
+            sleep(3000)
+            break
+        } else {
+            sleep(100)
+            if (max_try_time < 1){
+                assertEquals(1,2)
+            }
+        }
+    }
+
+    sql """ INSERT INTO ${tableName} VALUES
+            (1, '2017-10-01', 'Beijing', 10, 1, 1, 30, 20, hll_hash(1), 
to_bitmap(1))
+        """
+    sql """ INSERT INTO ${tableName} VALUES
+            (1, '2017-10-02', 'Beijing', 10, 1, 1, 31, 19, hll_hash(2), 
to_bitmap(2))
+        """
+    sql """ sync """
+
+    qt_select """ select * from ${tableName} order by user_id """
+
+    qt_select """ select user_id, sum(cost) from ${tableName} group by user_id 
order by user_id """
+
+    sql """ ALTER TABLE ${tableName} RENAME ROLLUP ${rollupName} 
new_${rollupName}"""
+
+    sql """ INSERT INTO ${tableName} VALUES
+            (2, '2017-10-01', 'Beijing', 10, 1, 1, 31, 21, hll_hash(2), 
to_bitmap(2))
+        """
+    sql """ INSERT INTO ${tableName} VALUES
+            (2, '2017-10-02', 'Beijing', 10, 1, 1, 32, 20, hll_hash(3), 
to_bitmap(3))
+        """
+    qt_desc """ desc ${tableName} ALL"""
+
+    qt_select""" select * from ${tableName} order by user_id """
+
+    qt_select """ select user_id, sum(cost) from ${tableName} group by user_id 
order by user_id """
+
+    sql """ DROP TABLE ${tableName} """
+}
+


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to