From c9272dfbbda0aca269a6a1f7a4bc7f1bb0744fc9 Mon Sep 17 00:00:00 2001 From: Murphy Date: Wed, 4 Sep 2024 16:41:05 +0800 Subject: [PATCH] sql test Signed-off-by: Murphy --- .../R/test_analyze_column | 102 ++++++++++++++++++ .../T/test_analyze_column | 56 ++++++++++ 2 files changed, 158 insertions(+) create mode 100644 test/sql/test_analyze_statistics/R/test_analyze_column create mode 100644 test/sql/test_analyze_statistics/T/test_analyze_column diff --git a/test/sql/test_analyze_statistics/R/test_analyze_column b/test/sql/test_analyze_statistics/R/test_analyze_column new file mode 100644 index 0000000000000..072c3a547454e --- /dev/null +++ b/test/sql/test_analyze_statistics/R/test_analyze_column @@ -0,0 +1,102 @@ +-- name: test_analyze_columnn +create database analyze_test_${uuid0}; +-- result: +-- !result +use analyze_test_${uuid0}; +-- result: +-- !result +CREATE TABLE `t1` ( + `k1` date, + `k2` datetime, + `k3` char(20), + `k4` varchar(20), + `k5` boolean, + `k6` tinyint, + `k7` smallint, + `k8` int, + `k9` bigint, + `k10` largeint, + `k11` float, + `k12` double, + `k13` decimal(27,9) ) +DUPLICATE KEY(`k1`, `k2`, `k3`, `k4`, `k5`) +DISTRIBUTED BY HASH(`k1`, `k2`, `k3`) BUCKETS 3 +PROPERTIES ('replication_num' = '1'); +-- result: +-- !result +admin set frontend config('enable_statistic_collect_on_first_load'='false'); +-- result: +-- !result +INSERT INTO t1 VALUES + ('2020-10-22','2020-10-23 12:12:12','k3','k4',0,1,2,3,4,5,1.1,1.12,2.889), + ('2020-10-23','2020-10-24 12:12:12','k3','k4',0,0,2,3,4,5,1.1,1.12,2.889), + ('2020-10-24','2020-10-25 12:12:12','k3','k4',0,1,2,3,4,5,1.1,1.12,2.889), + (null,'2020-10-26 12:12:12',null,null,null,null,null,null,null,null,1,1.12,2.889), + (null,'2020-10-27 12:12:12','k3','k4',0,1,2,3,4,5,1.1,1.12,2.889); +-- result: +-- !result +[UC] analyze sample table t1; +-- result: +analyze_test_8a14e06f2aaa4d4aa329877dfd869c7b.t1 sample status OK +-- !result +show stats meta where `database` = 'analyze_test_${uuid0}'; +-- result: +[REGEX]analyze_test_.* t1 ALL SAMPLE .* {} 100% +-- !result +[UC] analyze full table t1\(k1,k2\); +-- result: +analyze_test_8a14e06f2aaa4d4aa329877dfd869c7b.t1 analyze status OK +-- !result +show stats meta where `database` = 'analyze_test_${uuid0}'; +-- result: +[REGEX]analyze_test_.* t1 ALL SAMPLE .* {} 100% \(k1,FULL\),\(k2,FULL\) +-- !result +[UC] analyze full table t1\(k3,k4\); +-- result: +analyze_test_8a14e06f2aaa4d4aa329877dfd869c7b.t1 analyze status OK +-- !result +show stats meta where `database` = 'analyze_test_${uuid0}'; +-- result: +[REGEX]analyze_test_.* t1 ALL SAMPLE .* {} 100% \(k1,FULL\),\(k2,FULL\),\(k3,FULL\),\(k4,FULL\) +-- !result +[UC] analyze sample table t1\(k3,k4\); +-- result: +analyze_test_8a14e06f2aaa4d4aa329877dfd869c7b.t1 sample status OK +-- !result +show stats meta where `database` = 'analyze_test_${uuid0}'; +-- result: +[REGEX]analyze_test_.* t1 ALL SAMPLE .* {} 100% \(k1,FULL\),\(k2,FULL\),\(k3,SAMPLE\),\(k4,SAMPLE\) +-- !result +[UC] analyze sample table t1; +-- result: +analyze_test_8a14e06f2aaa4d4aa329877dfd869c7b.t1 sample status OK +-- !result +show stats meta where `database` = 'analyze_test_${uuid0}'; +-- result: +[REGEX]analyze_test_.* t1 ALL SAMPLE .* {} 100% \(k1,FULL\),\(k2,FULL\),\(k3,SAMPLE\),\(k4,SAMPLE\) +-- !result +[UC] analyze full table t1; +-- result: +analyze_test_8a14e06f2aaa4d4aa329877dfd869c7b.t1 analyze status OK +-- !result +show stats meta where `database` = 'analyze_test_${uuid0}'; +-- result: +[REGEX]analyze_test_.* t1 ALL FULL .* {} 100% \(k1,FULL\),\(k2,FULL\),\(k3,SAMPLE\),\(k4,SAMPLE\) +-- !result +[UC] drop stats t1; +-- result: +-- !result +show stats meta where `database` = 'analyze_test_${uuid0}'; +-- result: +-- !result +[UC] analyze sample table t1; +-- result: +analyze_test_8a14e06f2aaa4d4aa329877dfd869c7b.t1 sample status OK +-- !result +show stats meta where `database` = 'analyze_test_${uuid0}'; +-- result: +[REGEX]analyze_test_.* t1 ALL SAMPLE .* {} 100% +-- !result +admin set frontend config('enable_statistic_collect_on_first_load'='true'); +-- result: +-- !result \ No newline at end of file diff --git a/test/sql/test_analyze_statistics/T/test_analyze_column b/test/sql/test_analyze_statistics/T/test_analyze_column new file mode 100644 index 0000000000000..5678cda786fff --- /dev/null +++ b/test/sql/test_analyze_statistics/T/test_analyze_column @@ -0,0 +1,56 @@ +-- name: test_analyze_columnn +create database analyze_test_${uuid0}; +use analyze_test_${uuid0}; + + CREATE TABLE `t1` ( + `k1` date, + `k2` datetime, + `k3` char(20), + `k4` varchar(20), + `k5` boolean, + `k6` tinyint, + `k7` smallint, + `k8` int, + `k9` bigint, + `k10` largeint, + `k11` float, + `k12` double, + `k13` decimal(27,9) ) +DUPLICATE KEY(`k1`, `k2`, `k3`, `k4`, `k5`) +DISTRIBUTED BY HASH(`k1`, `k2`, `k3`) BUCKETS 3 +PROPERTIES ('replication_num' = '1'); + +admin set frontend config('enable_statistic_collect_on_first_load'='false'); + +INSERT INTO t1 VALUES + ('2020-10-22','2020-10-23 12:12:12','k3','k4',0,1,2,3,4,5,1.1,1.12,2.889), + ('2020-10-23','2020-10-24 12:12:12','k3','k4',0,0,2,3,4,5,1.1,1.12,2.889), + ('2020-10-24','2020-10-25 12:12:12','k3','k4',0,1,2,3,4,5,1.1,1.12,2.889), + (null,'2020-10-26 12:12:12',null,null,null,null,null,null,null,null,1,1.12,2.889), + (null,'2020-10-27 12:12:12','k3','k4',0,1,2,3,4,5,1.1,1.12,2.889); + +[UC] analyze sample table t1; +show stats meta where `database` = 'analyze_test_${uuid0}'; + +[UC] analyze full table t1(k1,k2); +show stats meta where `database` = 'analyze_test_${uuid0}'; + +[UC] analyze full table t1(k3,k4); +show stats meta where `database` = 'analyze_test_${uuid0}'; + +[UC] analyze sample table t1(k3,k4); +show stats meta where `database` = 'analyze_test_${uuid0}'; + +[UC] analyze sample table t1; +show stats meta where `database` = 'analyze_test_${uuid0}'; + +[UC] analyze full table t1; +show stats meta where `database` = 'analyze_test_${uuid0}'; + +[UC] drop stats t1; +show stats meta where `database` = 'analyze_test_${uuid0}'; + +[UC] analyze sample table t1; +show stats meta where `database` = 'analyze_test_${uuid0}'; + +admin set frontend config('enable_statistic_collect_on_first_load'='true'); \ No newline at end of file