Skip to content

Commit 19e0650

Browse files
Jibing-Lidataroaring
authored andcommitted
[fix](regression)Fix test_agg_complex_type fail case. Improve analyze_stats time consumption. (#37895)
Reduce time consumption of analyze_stats case. Fix cloud version failed case test_agg_complex_type, set force_sample_analyze to false.
1 parent 46f5e00 commit 19e0650

File tree

2 files changed

+23
-36
lines changed

2 files changed

+23
-36
lines changed

regression-test/suites/statistics/analyze_stats.groovy

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ suite("test_analyze") {
2424
String tbl = "analyzetestlimited_duplicate_all"
2525

2626
sql """set global force_sample_analyze=false"""
27+
sql """set global enable_auto_analyze=false"""
2728
sql """
2829
DROP DATABASE IF EXISTS `${db}`
2930
"""
@@ -164,14 +165,30 @@ suite("test_analyze") {
164165
exception = e
165166
}
166167

168+
// Test sample agg table value column. Min max is N/A when zone map is not available.
169+
sql """
170+
CREATE TABLE `agg_table_test` (
171+
`id` BIGINT NOT NULL,
172+
`name` VARCHAR(10) REPLACE NULL
173+
) ENGINE=OLAP
174+
AGGREGATE KEY(`id`)
175+
COMMENT 'OLAP'
176+
DISTRIBUTED BY HASH(`id`) BUCKETS 32
177+
PROPERTIES (
178+
"replication_num" = "1"
179+
);
180+
"""
181+
sql """insert into agg_table_test values (1,'name1'), (2, 'name2')"""
182+
sql """analyze table agg_table_test with sample rows 100 with sync"""
183+
def agg_result = sql """show column stats agg_table_test (name)"""
184+
logger.info("show column agg_table_test(name) stats: " + agg_result)
185+
assertEquals(agg_result[0][7], "N/A")
186+
assertEquals(agg_result[0][8], "N/A")
187+
167188
def a_result_1 = sql """
168189
ANALYZE DATABASE ${db} WITH SYNC WITH SAMPLE PERCENT 10
169190
"""
170191

171-
def a_result_2 = sql """
172-
ANALYZE DATABASE ${db} WITH SYNC WITH SAMPLE PERCENT 5
173-
"""
174-
175192
def a_result_3 = sql """
176193
ANALYZE DATABASE ${db} WITH SAMPLE PERCENT 5
177194
"""
@@ -1149,24 +1166,14 @@ PARTITION `p599` VALUES IN (599)
11491166
sql """ANALYZE TABLE test_updated_rows WITH SYNC"""
11501167
sql """ INSERT INTO test_updated_rows VALUES('1',1,1); """
11511168
def cnt1 = sql """ SHOW TABLE STATS test_updated_rows """
1152-
for (int i = 0; i < 10; ++i) {
1153-
if (Integer.valueOf(cnt1[0][0]) == 8) break;
1154-
Thread.sleep(1000) // rows updated report is async
1155-
cnt1 = sql """ SHOW TABLE STATS test_updated_rows """
1156-
}
11571169
assertEquals(Integer.valueOf(cnt1[0][0]), 1)
11581170
sql """ANALYZE TABLE test_updated_rows WITH SYNC"""
11591171
sql """ INSERT INTO test_updated_rows SELECT * FROM test_updated_rows """
11601172
sql """ INSERT INTO test_updated_rows SELECT * FROM test_updated_rows """
11611173
sql """ INSERT INTO test_updated_rows SELECT * FROM test_updated_rows """
11621174
sql """ANALYZE TABLE test_updated_rows WITH SYNC"""
11631175
def cnt2 = sql """ SHOW TABLE STATS test_updated_rows """
1164-
for (int i = 0; i < 10; ++i) {
1165-
if (Integer.valueOf(cnt2[0][0]) == 8) break;
1166-
Thread.sleep(1000) // rows updated report is async
1167-
cnt2 = sql """ SHOW TABLE STATS test_updated_rows """
1168-
}
1169-
assertTrue(Integer.valueOf(cnt2[0][0]) == 0 || Integer.valueOf(cnt2[0][0]) == 8)
1176+
assertEquals(Integer.valueOf(cnt2[0][0]), 8)
11701177

11711178
// test analyze specific column
11721179
sql """CREATE TABLE test_analyze_specific_column (col1 varchar(11451) not null, col2 int not null, col3 int not null)
@@ -2625,27 +2632,6 @@ PARTITION `p599` VALUES IN (599)
26252632
partition_result = sql """show table stats partition_test"""
26262633
assertEquals(partition_result[0][6], "false")
26272634

2628-
// Test sample agg table value column
2629-
sql """
2630-
CREATE TABLE `agg_table_test` (
2631-
`id` BIGINT NOT NULL,
2632-
`name` VARCHAR(10) REPLACE NULL
2633-
) ENGINE=OLAP
2634-
AGGREGATE KEY(`id`)
2635-
COMMENT 'OLAP'
2636-
DISTRIBUTED BY HASH(`id`) BUCKETS 32
2637-
PROPERTIES (
2638-
"replication_num" = "1"
2639-
);
2640-
"""
2641-
sql """insert into agg_table_test values (1,'name1'), (2, 'name2')"""
2642-
Thread.sleep(1000 * 60)
2643-
sql """analyze table agg_table_test with sample rows 100 with sync"""
2644-
def agg_result = sql """show column stats agg_table_test (name)"""
2645-
logger.info("show column agg_table_test(name) stats: " + agg_result)
2646-
assertEquals(agg_result[0][7], "N/A")
2647-
assertEquals(agg_result[0][8], "N/A")
2648-
26492635
// Test sample string type min max
26502636
sql """
26512637
CREATE TABLE `string_min_max` (

regression-test/suites/statistics/test_agg_complex_type.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ suite("test_analyze_with_agg_complex_type") {
3636

3737
sql """insert into test_agg_complex_type values (2, to_bitmap(1), hll_hash("12"), TO_QUANTILE_STATE("11", 1.0), max_by_state(1,2));"""
3838

39+
sql """set global force_sample_analyze=false"""
3940
sql """ANALYZE TABLE test_agg_complex_type WITH SYNC"""
4041

4142
def show_result = sql """SHOW COLUMN CACHED STATS test_agg_complex_type"""

0 commit comments

Comments
 (0)