@@ -31,6 +31,7 @@ use databend_common_meta_app::schema::GcDroppedTableReq;
3131use databend_common_meta_app:: schema:: ListDroppedTableReq ;
3232use databend_common_meta_app:: schema:: TableInfoFilter ;
3333use databend_common_sql:: plans:: VacuumDropTablePlan ;
34+ use databend_common_storages_view:: view_table:: VIEW_ENGINE ;
3435use databend_enterprise_vacuum_handler:: get_vacuum_handler;
3536use log:: info;
3637
@@ -149,13 +150,17 @@ impl Interpreter for VacuumDropTablesInterpreter {
149150 drop_ids
150151 ) ;
151152
152- // TODO buggy, table as catalog obj should be allowed to drop
153- // also drop ids
154- // filter out read-only tables
155- let tables = tables
153+ // Filter out read-only tables and views.
154+ // Note: The drop_ids list still includes view IDs
155+ let ( views, tables) : ( Vec < _ > , Vec < _ > ) = tables
156156 . into_iter ( )
157157 . filter ( |tbl| !tbl. as_ref ( ) . is_read_only ( ) )
158- . collect :: < Vec < _ > > ( ) ;
158+ . partition ( |tbl| tbl. get_table_info ( ) . meta . engine == VIEW_ENGINE ) ;
159+
160+ {
161+ let view_ids = views. into_iter ( ) . map ( |v| v. get_id ( ) ) . collect :: < Vec < _ > > ( ) ;
162+ info ! ( "view ids excluded from purging data: {:?}" , view_ids) ;
163+ }
159164
160165 let handler = get_vacuum_handler ( ) ;
161166 let threads_nums = self . ctx . get_settings ( ) . get_max_threads ( ) ? as usize ;
@@ -173,6 +178,8 @@ impl Interpreter for VacuumDropTablesInterpreter {
173178 // gc meta data only when not dry run
174179 if self . plan . option . dry_run . is_none ( ) {
175180 let mut success_dropped_ids = vec ! [ ] ;
181+ // Since drop_ids contains view IDs, any views (if present) will be added to
182+ // the success_dropped_id list, with removal from the meta-server attempted later.
176183 for drop_id in drop_ids {
177184 match & drop_id {
178185 DroppedId :: Db {
@@ -205,6 +212,7 @@ impl Interpreter for VacuumDropTablesInterpreter {
205212 "failed dbs:{:?}, failed_tables:{:?}, success_drop_ids:{:?}" ,
206213 failed_dbs, failed_tables, success_dropped_ids
207214 ) ;
215+
208216 self . gc_drop_tables ( catalog, success_dropped_ids) . await ?;
209217 }
210218
0 commit comments