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

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


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 2229089a1a1 [regression](fe) Add more regression test for FE (#25976) 
(#26263)
2229089a1a1 is described below

commit 2229089a1a1dea779c8d493de3a4fa8ea2c692a5
Author: Lei Zhang <27994433+swjtu-zhang...@users.noreply.github.com>
AuthorDate: Thu Nov 2 20:24:53 2023 +0800

    [regression](fe) Add more regression test for FE (#25976) (#26263)
---
 regression-test/data/database_p0/test_alter_db.out |  7 ++
 .../test_alter_table_property_bucket.out           | 19 +++++
 .../schema_change_p0/test_rename_partition.out     |  9 +++
 .../data/schema_change_p0/test_rename_table.out    |  7 ++
 .../suites/database_p0/test_alter_db.groovy        | 84 ++++++++++++++++++++++
 .../test_alter_table_property_bucket.groovy        | 77 ++++++++++++++++++++
 .../schema_change_p0/test_rename_partition.groovy  | 58 +++++++++++++++
 .../schema_change_p0/test_rename_table.groovy      | 54 ++++++++++++++
 8 files changed, 315 insertions(+)

diff --git a/regression-test/data/database_p0/test_alter_db.out 
b/regression-test/data/database_p0/test_alter_db.out
new file mode 100644
index 00000000000..143060cdb80
--- /dev/null
+++ b/regression-test/data/database_p0/test_alter_db.out
@@ -0,0 +1,7 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+1      1       xxx     1
+
+-- !sql --
+1      1       xxx     1
+
diff --git 
a/regression-test/data/schema_change/test_alter_table_property_bucket.out 
b/regression-test/data/schema_change/test_alter_table_property_bucket.out
new file mode 100644
index 00000000000..7b62786c638
--- /dev/null
+++ b/regression-test/data/schema_change/test_alter_table_property_bucket.out
@@ -0,0 +1,19 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !order --
+1      2017-01-01      Beijing 10      1       1       30      20      \N      
\N
+2      2017-02-01      Beijing 10      1       1       31      19      \N      
\N
+3      2017-03-01      Beijing 10      1       1       31      21      \N      
\N
+
+-- !order --
+1      2017-01-01      Beijing 10      1       1       30      20      \N      
\N
+2      2017-02-01      Beijing 10      1       1       31      19      \N      
\N
+3      2017-03-01      Beijing 10      1       1       31      21      \N      
\N
+4      2017-03-01      Beijing 10      1       1       31      21      \N      
\N
+
+-- !order --
+1      2017-01-01      Beijing 10      1       1       30      20      \N      
\N
+2      2017-02-01      Beijing 10      1       1       31      19      \N      
\N
+3      2017-03-01      Beijing 10      1       1       31      21      \N      
\N
+4      2017-03-01      Beijing 10      1       1       31      21      \N      
\N
+5      2017-03-01      Beijing 10      1       1       31      21      \N      
\N
+
diff --git a/regression-test/data/schema_change_p0/test_rename_partition.out 
b/regression-test/data/schema_change_p0/test_rename_partition.out
new file mode 100644
index 00000000000..c63694b554a
--- /dev/null
+++ b/regression-test/data/schema_change_p0/test_rename_partition.out
@@ -0,0 +1,9 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+1      1       xxx     1
+2      1       yyy     1
+
+-- !sql --
+1      1       xxx     1
+2      1       yyy     1
+
diff --git a/regression-test/data/schema_change_p0/test_rename_table.out 
b/regression-test/data/schema_change_p0/test_rename_table.out
new file mode 100644
index 00000000000..143060cdb80
--- /dev/null
+++ b/regression-test/data/schema_change_p0/test_rename_table.out
@@ -0,0 +1,7 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+1      1       xxx     1
+
+-- !sql --
+1      1       xxx     1
+
diff --git a/regression-test/suites/database_p0/test_alter_db.groovy 
b/regression-test/suites/database_p0/test_alter_db.groovy
new file mode 100644
index 00000000000..15e96ba51f4
--- /dev/null
+++ b/regression-test/suites/database_p0/test_alter_db.groovy
@@ -0,0 +1,84 @@
+// 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_db") {
+    String dbName = "test_alter_db_qwer"
+    String newDbName = "new_alter_db_qwer"
+    String tableName = "t1_qwer"
+
+    sql """DROP DATABASE IF EXISTS ${dbName} FORCE;"""
+    sql """DROP DATABASE IF EXISTS ${newDbName} FORCE;"""
+
+    sql """CREATE DATABASE ${dbName};"""
+
+    sql """ALTER DATABASE ${dbName} SET DATA QUOTA 102400;"""
+    sql """ALTER DATABASE ${dbName} SET REPLICA QUOTA 1024;"""
+    sql """ALTER DATABASE ${dbName} SET TRANSACTION QUOTA 1024;"""
+
+    def dbResults = sql """SHOW PROC '/dbs';"""
+    def found = false
+    def result = null
+    for (def dbResult : dbResults) {
+        logger.debug("dbResult:${dbResult}")
+        if (dbResult[1].contains(dbName)) {
+            found = true
+            result = dbResult
+            break;
+        }
+    }
+    assertTrue(found)
+    assertEquals("100.000 KB", result[4])
+    assertEquals("1024", result[7])
+    assertEquals("1024", result[8])
+
+    sql """use ${dbName};"""
+    sql """
+        CREATE TABLE `${tableName}`
+        (
+            `siteid` INT DEFAULT '10',
+            `citycode` SMALLINT,
+            `username` VARCHAR(32) DEFAULT 'test',
+            `pv` BIGINT SUM DEFAULT '0'
+        )
+        AGGREGATE KEY(`siteid`, `citycode`, `username`)
+        DISTRIBUTED BY HASH(siteid) BUCKETS 1
+        PROPERTIES (
+            "replication_num" = "1"
+        );
+    """
+
+    sql """INSERT INTO ${dbName}.${tableName}(siteid, citycode, username, pv) 
VALUES (1, 1, "xxx", 1);"""
+    sql """SYNC;"""
+    order_qt_sql """SELECT * FROM ${dbName}.${tableName};"""
+
+    sql """ ALTER DATABASE ${dbName} RENAME ${newDbName};"""
+    order_qt_sql """SELECT * FROM ${newDbName}.${tableName};"""
+
+    dbResults = sql """SHOW PROC '/dbs';"""
+    found = false
+    for (def dbResult : dbResults) {
+        logger.debug("dbResult:${dbResult}")
+        if (dbResult[1].contains(dbName)) {
+            found = true
+            break;
+        }
+    }
+    assertFalse(found)
+
+    sql """DROP DATABASE IF EXISTS ${dbName} FORCE;"""
+    sql """DROP DATABASE IF EXISTS ${newDbName} FORCE;"""
+}
diff --git 
a/regression-test/suites/schema_change/test_alter_table_property_bucket.groovy 
b/regression-test/suites/schema_change/test_alter_table_property_bucket.groovy
new file mode 100644
index 00000000000..bf7b81d06cd
--- /dev/null
+++ 
b/regression-test/suites/schema_change/test_alter_table_property_bucket.groovy
@@ -0,0 +1,77 @@
+// 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_bucket") {
+    def tableName = "test_alter_table_property_bucket"
+
+    sql "DROP TABLE IF EXISTS ${tableName} FORCE"
+    sql """
+        CREATE TABLE ${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`)
+        PARTITION BY RANGE(`date`)
+        (
+            PARTITION `p201701` VALUES LESS THAN ("2017-02-01"),
+            PARTITION `p201702` VALUES LESS THAN ("2017-03-01"),
+            PARTITION `p201703` VALUES LESS THAN ("2017-04-01")
+        )
+        DISTRIBUTED BY HASH(`user_id`)
+        BUCKETS 1
+        PROPERTIES (
+                "replication_num" = "1"
+            );
+        ;
+        """
+
+    sql """ INSERT INTO ${tableName} VALUES
+            (1, '2017-01-01', 'Beijing', 10, 1, 1, 30, 20, hll_hash(1), 
to_bitmap(1)),
+            (2, '2017-02-01', 'Beijing', 10, 1, 1, 31, 19, hll_hash(2), 
to_bitmap(2)),
+            (3, '2017-03-01', 'Beijing', 10, 1, 1, 31, 21, hll_hash(2), 
to_bitmap(2))
+        """
+
+    qt_order """ select * from ${tableName} order by user_id"""
+
+    // modify in_memory property
+    // https://github.com/apache/doris/pull/18731
+    test {
+        sql """ALTER TABLE ${tableName} SET ("in_memory" = "true");"""
+        exception "Not support set 'in_memory'='true' now!"
+    }
+
+    sql """ INSERT INTO ${tableName} VALUES
+            (4, '2017-03-01', 'Beijing', 10, 1, 1, 31, 21, hll_hash(2), 
to_bitmap(2))
+        """
+
+    qt_order """ select * from ${tableName} order by user_id"""
+
+    // modify bucket num
+    sql """ALTER TABLE ${tableName} MODIFY DISTRIBUTION DISTRIBUTED BY 
HASH(user_id) BUCKETS 2;"""
+
+    sql """ INSERT INTO ${tableName} VALUES
+            (5, '2017-03-01', 'Beijing', 10, 1, 1, 31, 21, hll_hash(2), 
to_bitmap(2))
+        """
+    qt_order """ select * from ${tableName} order by user_id"""
+}
\ No newline at end of file
diff --git 
a/regression-test/suites/schema_change_p0/test_rename_partition.groovy 
b/regression-test/suites/schema_change_p0/test_rename_partition.groovy
new file mode 100644
index 00000000000..eb3d65fcd53
--- /dev/null
+++ b/regression-test/suites/schema_change_p0/test_rename_partition.groovy
@@ -0,0 +1,58 @@
+// 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_partition") {
+    String tblName = "test_rename_partition"
+    sql """DROP TABLE IF EXISTS ${tblName} FORCE; """
+
+    sql """
+        CREATE TABLE `${tblName}`
+        (
+            `siteid` INT DEFAULT '10',
+            `citycode` SMALLINT,
+            `username` VARCHAR(32) DEFAULT 'test',
+            `pv` BIGINT SUM DEFAULT '0'
+        )
+        AGGREGATE KEY(`siteid`, `citycode`, `username`)
+        PARTITION BY RANGE(`siteid`)
+                (
+                    partition `old_p1` values [("1"), ("2")),
+                    partition `old_p2` values [("2"), ("3"))
+                )
+        DISTRIBUTED BY HASH(siteid) BUCKETS 1
+        PROPERTIES (
+            "replication_num" = "1"
+        );
+    """
+
+    sql """INSERT INTO ${tblName}(siteid, citycode, username, pv) VALUES (1, 
1, "xxx", 1), (2, 1, "yyy", 1);"""
+    sql """SYNC;"""
+    order_qt_sql """SELECT * from ${tblName};"""
+
+    sql """ALTER TABLE ${tblName} RENAME PARTITION old_p1 new_p1;"""
+    order_qt_sql """SELECT * from ${tblName};"""
+
+    def results = sql """SHOW PARTITIONS FROM ${tblName};"""
+    for (def result : results) {
+        logger.info("result:${result}")
+        if (["new_p1", "old_p2"].contains(result[1])) {
+            continue;
+        }
+        assertTrue(false);
+    }
+    sql """DROP TABLE IF EXISTS ${tblName} FORCE; """
+}
diff --git a/regression-test/suites/schema_change_p0/test_rename_table.groovy 
b/regression-test/suites/schema_change_p0/test_rename_table.groovy
new file mode 100644
index 00000000000..825b702d0e6
--- /dev/null
+++ b/regression-test/suites/schema_change_p0/test_rename_table.groovy
@@ -0,0 +1,54 @@
+// 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_table") {
+    String tblName = "test_rename_table"
+    String newTblName = "new_rename_table"
+
+    sql """DROP TABLE IF EXISTS ${tblName} FORCE; """
+    sql """DROP TABLE IF EXISTS ${newTblName} FORCE; """
+
+    sql """
+        CREATE TABLE `${tblName}`
+        (
+            `siteid` INT DEFAULT '10',
+            `citycode` SMALLINT,
+            `username` VARCHAR(32) DEFAULT 'test',
+            `pv` BIGINT SUM DEFAULT '0'
+        )
+        AGGREGATE KEY(`siteid`, `citycode`, `username`)
+        DISTRIBUTED BY HASH(siteid) BUCKETS 1
+        PROPERTIES (
+            "replication_num" = "1"
+        );
+    """
+
+    sql """INSERT INTO ${tblName}(siteid, citycode, username, pv) VALUES (1, 
1, "xxx", 1);"""
+    sql """SYNC;"""
+    order_qt_sql """SELECT * from ${tblName};"""
+
+    sql """ALTER TABLE ${tblName} RENAME ${newTblName};"""
+    order_qt_sql """SELECT * from ${newTblName};"""
+
+    String result = sql """SHOW TABLES;"""
+
+    assertFalse(result.contains(tblName))
+    assertTrue(result.contains(newTblName))
+
+    sql """DROP TABLE IF EXISTS ${tblName} FORCE; """
+    sql """DROP TABLE IF EXISTS ${newTblName} FORCE; """
+}


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

Reply via email to