Skip to content

Commit b8cef49

Browse files
committed
fix test
1 parent f10fee3 commit b8cef49

File tree

2 files changed

+76
-18
lines changed

2 files changed

+76
-18
lines changed

src/query/service/tests/it/storages/fuse/operations/analyze.rs

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,23 +100,37 @@ async fn test_fuse_snapshot_analyze_purge() -> Result<()> {
100100
let case_name = "analyze_statistic_purge";
101101
do_insertions(&fixture).await?;
102102

103-
// optimize statistics three times
104-
for i in 0..3 {
105-
analyze_table(&fixture).await?;
106-
check_data_dir(
107-
&fixture,
108-
case_name,
109-
3 + i,
110-
1 + i,
111-
2,
112-
2,
113-
2,
114-
2,
115-
Some(()),
116-
None,
117-
)
118-
.await?;
119-
}
103+
analyze_table(&fixture).await?;
104+
check_data_dir(
105+
&fixture,
106+
case_name,
107+
3,
108+
1,
109+
2,
110+
2,
111+
2,
112+
2,
113+
Some(()),
114+
None,
115+
)
116+
.await?;
117+
118+
119+
append_sample_data(1, &fixture).await?;
120+
analyze_table(&fixture).await?;
121+
check_data_dir(
122+
&fixture,
123+
case_name,
124+
5,
125+
2,
126+
3,
127+
3,
128+
3,
129+
2,
130+
Some(()),
131+
None,
132+
)
133+
.await?;
120134

121135
// Purge will keep at least two snapshots.
122136
let table = fixture.latest_default_table().await?;
@@ -126,7 +140,7 @@ async fn test_fuse_snapshot_analyze_purge() -> Result<()> {
126140
fuse_table
127141
.do_purge(&table_ctx, snapshot_files, None, true, false)
128142
.await?;
129-
check_data_dir(&fixture, case_name, 1, 1, 1, 1, 1, 1, Some(()), Some(())).await?;
143+
check_data_dir(&fixture, case_name, 1, 1, 2, 2, 2, 1, Some(()), Some(())).await?;
130144

131145
Ok(())
132146
}

tests/sqllogictests/suites/base/09_fuse_engine/09_0020_analyze.test

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,5 +243,49 @@ select count() from fuse_snapshot('db_09_0020','t2');
243243
statement ok
244244
DROP TABLE t2;
245245

246+
statement ok
247+
CREATE TABLE t3(a int, b string) approx_distinct_columns = '';
248+
249+
statement ok
250+
insert into t3 values(1, 'a'), (2, 'b');
251+
252+
statement ok
253+
alter table t3 set options(approx_distinct_columns = 'a, b');
254+
255+
statement ok
256+
insert into t3 values(4, 'c'), (3, 'b');
257+
258+
query B
259+
select segment_stats_size is null from fuse_segment('db_09_0020','t3') order by file_location;
260+
----
261+
1
262+
0
263+
264+
statement ok
265+
analyze table t3;
266+
267+
query B
268+
select segment_stats_size is null from fuse_segment('db_09_0020','t3') order by file_location;
269+
----
270+
0
271+
0
272+
273+
query T
274+
select * from fuse_statistic('db_09_0020', 't3') order by column_name;
275+
----
276+
a 4 (empty)
277+
b 3 (empty)
278+
279+
statement ok
280+
analyze table t3;
281+
282+
query I
283+
select count() from fuse_snapshot('db_09_0020', 't3');
284+
----
285+
3
286+
287+
statement ok
288+
DROP TABLE t3;
289+
246290
statement ok
247291
DROP DATABASE db_09_0020

0 commit comments

Comments
 (0)