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

morrysnow 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 309037aa81d [test](stats)Add upgrade and downgrade test for analyze 
(#42855)
309037aa81d is described below

commit 309037aa81df76470cfaa67f5cb89f29f446713f
Author: zfr95 <87513668+zfr9...@users.noreply.github.com>
AuthorDate: Fri Nov 1 11:39:28 2024 +0800

    [test](stats)Add upgrade and downgrade test for analyze (#42855)
    
    Mainly test the basic functions of collecting statistical information,
    including operations such as analyze and show. Mainly worry about
    metadata information such as changes in statistical information tables
    leading to problems in upgrading and downgrading versions. Here, judge
    whether there will be problems with test cases on the new and old
    versions to check.
---
 regression-test/suites/stats_up_down/load.groovy   | 66 +++++++++++++++++++
 .../test_upgrade_downgrade_stats.groovy            | 75 ++++++++++++++++++++++
 2 files changed, 141 insertions(+)

diff --git a/regression-test/suites/stats_up_down/load.groovy 
b/regression-test/suites/stats_up_down/load.groovy
new file mode 100644
index 00000000000..57fe3d0dd12
--- /dev/null
+++ b/regression-test/suites/stats_up_down/load.groovy
@@ -0,0 +1,66 @@
+// 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_upgrade_downgrade_prepare_stats","p0,stats,restart_fe") {
+
+    String db = context.config.getDbNameByFile(context.file)
+    sql "use ${db}"
+
+    sql """
+    drop table if exists orders_stats
+    """
+
+    sql """CREATE TABLE `orders_stats` (
+      `o_orderkey` BIGINT NULL,
+      `o_custkey` INT NULL,
+      `o_orderstatus` VARCHAR(1) NULL,
+      `o_totalprice` DECIMAL(15, 2)  NULL,
+      `o_orderpriority` VARCHAR(15) NULL,
+      `o_clerk` VARCHAR(15) NULL,
+      `o_shippriority` INT NULL,
+      `o_comment` VARCHAR(79) NULL,
+      `o_orderdate` DATE not NULL
+    ) ENGINE=OLAP
+    DUPLICATE KEY(`o_orderkey`, `o_custkey`)
+    COMMENT 'OLAP'
+    DISTRIBUTED BY HASH(`o_orderkey`) BUCKETS 96
+    PROPERTIES (
+    "replication_allocation" = "tag.location.default: 1"
+    );"""
+
+    sql """
+    insert into orders_stats values 
+    (null, 1, 'k', 99.5, 'a', 'b', 1, 'yy', '2023-10-17'),
+    (1, null, 'o', 109.2, 'c','d',2, 'mm', '2023-10-17'),
+    (3, 3, null, 99.5, 'a', 'b', 1, 'yy', '2023-10-19'),
+    (1, 2, 'o', null, 'a', 'b', 1, 'yy', '2023-10-20'),
+    (2, 3, 'k', 109.2, null,'d',2, 'mm', '2023-10-21'),
+    (3, 1, 'k', 99.5, 'a', null, 1, 'yy', '2023-10-22'),
+    (1, 3, 'o', 99.5, 'a', 'b', null, 'yy', '2023-10-19'),
+    (2, 1, 'o', 109.2, 'c','d',2, null, '2023-10-18'),
+    (3, 2, 'k', 99.5, 'a', 'b', 1, 'yy', '2023-10-17'),
+    (4, 5, 'k', 99.5, 'a', 'b', 1, 'yy', '2023-10-19'); 
+    """
+
+    sql """analyze table orders_stats with sync"""
+
+    def tb_stats = sql """show table stats orders_stats;"""
+    assertTrue(tb_stats.size() == 1)
+
+    def col_stats = sql """show column stats orders_stats;"""
+    assertTrue(col_stats.size() == 9)
+}
diff --git 
a/regression-test/suites/stats_up_down/test_upgrade_downgrade_stats.groovy 
b/regression-test/suites/stats_up_down/test_upgrade_downgrade_stats.groovy
new file mode 100644
index 00000000000..978928390c4
--- /dev/null
+++ b/regression-test/suites/stats_up_down/test_upgrade_downgrade_stats.groovy
@@ -0,0 +1,75 @@
+// 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_upgrade_downgrade_compatibility_stats","p0,stats,restart_fe") {
+    String db = context.config.getDbNameByFile(context.file)
+    sql "use ${db}"
+
+    def tb_stats = sql """show table stats orders_stats;"""
+    assertTrue(tb_stats.size() == 1)
+
+    def col_stats = sql """show column stats orders_stats;"""
+    assertTrue(col_stats.size() == 9)
+
+    sql """
+    drop table if exists lineitem_stats
+    """
+
+    sql """CREATE TABLE `lineitem_stats` (
+      `l_orderkey` BIGINT NULL,
+      `l_linenumber` INT NULL,
+      `l_partkey` INT NULL,
+      `l_suppkey` INT NULL,
+      `l_quantity` DECIMAL(15, 2) NULL,
+      `l_extendedprice` DECIMAL(15, 2) NULL,
+      `l_discount` DECIMAL(15, 2) NULL,
+      `l_tax` DECIMAL(15, 2) NULL,
+      `l_returnflag` VARCHAR(1) NULL,
+      `l_linestatus` VARCHAR(1) NULL,
+      `l_commitdate` DATE NULL,
+      `l_receiptdate` DATE NULL,
+      `l_shipinstruct` VARCHAR(25) NULL,
+      `l_shipmode` VARCHAR(10) NULL,
+      `l_comment` VARCHAR(44) NULL,
+      `l_shipdate` DATE not NULL
+    ) ENGINE=OLAP
+    DUPLICATE KEY(l_orderkey, l_linenumber, l_partkey, l_suppkey )
+    COMMENT 'OLAP'
+    DISTRIBUTED BY HASH(`l_orderkey`) BUCKETS 96
+    PROPERTIES (
+    "replication_allocation" = "tag.location.default: 1"
+    );"""
+
+    sql """
+    insert into lineitem_stats values 
+    (null, 1, 2, 3, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-17', '2023-10-17', 
'a', 'b', 'yyyyyyyyy', '2023-10-17'),
+    (1, null, 3, 1, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-18', '2023-10-18', 
'a', 'b', 'yyyyyyyyy', '2023-10-17'),
+    (3, 3, null, 2, 7.5, 8.5, 9.5, 10.5, 'k', 'o', '2023-10-19', '2023-10-19', 
'c', 'd', 'xxxxxxxxx', '2023-10-19'),
+    (1, 2, 3, null, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-17', '2023-10-17', 
'a', 'b', 'yyyyyyyyy', '2023-10-17'),
+    (2, 3, 2, 1, 5.5, 6.5, 7.5, 8.5, 'o', 'k', null, '2023-10-18', 'a', 'b', 
'yyyyyyyyy', '2023-10-18'),
+    (3, 1, 1, 2, 7.5, 8.5, 9.5, 10.5, 'k', 'o', '2023-10-19', null, 'c', 'd', 
'xxxxxxxxx', '2023-10-19'),
+    (1, 3, 2, 2, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-17', '2023-10-17', 
'a', 'b', 'yyyyyyyyy', '2023-10-17');
+    """
+
+    sql """analyze table lineitem_stats with sync;"""
+
+    def tb_stats2 = sql """show table stats lineitem_stats;"""
+    assertTrue(tb_stats2.size() == 1)
+
+    def col_stats2 = sql """show column stats lineitem_stats;"""
+    assertTrue(col_stats2.size() == 16)
+}


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

Reply via email to