@@ -30,6 +30,12 @@ set enable_auto_vacuum = 1;
3030statement ok
3131create or replace table t (c int) 'fs:///tmp/auto_vacuum/';
3232
33+ statement ok
34+ create or replace stage stage_av url = 'fs:///tmp/auto_vacuum/';
35+
36+ statement ok
37+ remove @stage_av/ pattern = '.*';
38+
3339# prepare data
3440statement ok
3541insert into t values(1);
@@ -40,8 +46,6 @@ insert into t values(2);
4046statement ok
4147insert into t values(3);
4248
43- statement ok
44- create or replace stage stage_av url = 'fs:///tmp/auto_vacuum/';
4549
4650# expect there are 3 segments/blocks/snapshots
4751onlyif http
@@ -113,10 +117,14 @@ statement ok
113117create or replace table t (c int) 'fs:///tmp/auto_vacuum_case2/';
114118
115119statement ok
116- alter table t set options(data_retention_period_in_hours = 0) ;
120+ create or replace stage stage_av url = 'fs:///tmp/auto_vacuum_case2/' ;
117121
118122statement ok
119- create or replace stage stage_av url = 'fs:///tmp/auto_vacuum_case2/';
123+ remove @stage_av/ pattern = '.*';
124+
125+ statement ok
126+ alter table t set options(data_retention_period_in_hours = 0);
127+
120128
121129statement ok
122130insert into t values(1);
@@ -150,13 +158,23 @@ select count() from list_stage(location=> '@stage_av') where name like '%_ss%';
150158# Test autovacuum policy `ByNumSnapshotsToKeep` #
151159#################################################
152160
161+ # Setting retention period to zero enables aggressive but safe vacuuming:
162+ # All historical data not referenced by the latest snapshot will be removed.
163+ # Note: With zero retention, concurrent transaction conflicts cannot be resolved.
164+ # Only the first committed transaction succeeds; all others will be aborted.
165+ statement ok
166+ set data_retention_time_in_days = 0;
167+
153168# CASE 1: Create table with data_retention_num_snapshots_to_keep table option
154169statement ok
155170create or replace table t (c int) 'fs:///tmp/auto_vacuum_case3/' data_retention_num_snapshots_to_keep = 3;
156171
157172statement ok
158173create or replace stage stage_av url = 'fs:///tmp/auto_vacuum_case3/';
159174
175+ statement ok
176+ remove @stage_av/ pattern = '.*';
177+
160178statement ok
161179set enable_auto_vacuum = 1;
162180
@@ -174,7 +192,7 @@ insert into t values(4);
174192
175193
176194# Insert 4 time, but only 3 snapshots will be kept
177- onlyif mysql
195+ onlyif http
178196query I
179197select count() from list_stage(location=> '@stage_av') where name like '%_ss%';
180198----
@@ -190,19 +208,19 @@ insert into t values(5);
190208statement ok
191209optimize table t compact;
192210
193- onlyif mysql
211+ onlyif http
194212query I
195213select count() from list_stage(location=> '@stage_av') where name like '%_sg%';
196214----
1972151
198216
199- onlyif mysql
217+ onlyif http
200218query I
201219select count() from list_stage(location=> '@stage_av') where name like '%\/_b\/%';
202220----
2032211
204222
205- onlyif mysql
223+ onlyif http
206224query I
207225select count() from list_stage(location=> '@stage_av') where name like '%_ss%';
208226----
@@ -229,4 +247,3 @@ remove @stage_av;
229247
230248statement ok
231249drop stage stage_av;
232-
0 commit comments