1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15+ use std:: collections:: BTreeSet ;
1516use std:: collections:: HashMap ;
1617use std:: collections:: HashSet ;
1718use std:: sync:: Arc ;
@@ -252,7 +253,7 @@ where TablesTable<WITH_HISTORY, WITHOUT_VIEW>: HistoryAware
252253 let user_api = UserApiProvider :: instance ( ) ;
253254
254255 let mut dbs = Vec :: new ( ) ;
255- let mut tables_names: Vec < String > = Vec :: new ( ) ;
256+ let mut tables_names: BTreeSet < String > = BTreeSet :: new ( ) ;
256257 let mut invalid_tables_ids = false ;
257258 let mut tables_ids: Vec < u64 > = Vec :: new ( ) ;
258259 let mut db_name: Vec < String > = Vec :: new ( ) ;
@@ -318,7 +319,7 @@ where TablesTable<WITH_HISTORY, WITHOUT_VIEW>: HistoryAware
318319 } else if col_name == "name" {
319320 if let Scalar :: String ( t_name) = scalar {
320321 if !tables_names. contains ( t_name) {
321- tables_names. push ( t_name. clone ( ) ) ;
322+ tables_names. insert ( t_name. clone ( ) ) ;
322323 }
323324 }
324325 }
@@ -353,12 +354,8 @@ where TablesTable<WITH_HISTORY, WITHOUT_VIEW>: HistoryAware
353354 . await
354355 {
355356 Ok ( new_tables) => {
356- let new_table_names: Vec < _ > = new_tables
357- . into_iter ( )
358- . flatten ( )
359- . filter ( |table| !tables_names. contains ( table) )
360- . collect ( ) ;
361-
357+ let new_table_names: BTreeSet < _ > =
358+ new_tables. into_iter ( ) . flatten ( ) . collect ( ) ;
362359 tables_names. extend ( new_table_names) ;
363360 }
364361 Err ( err) => {
@@ -434,6 +431,10 @@ where TablesTable<WITH_HISTORY, WITHOUT_VIEW>: HistoryAware
434431 }
435432 }
436433 }
434+ println ! (
435+ "with_history: {:?}, will call mget_table_names_by_ids" ,
436+ WITH_HISTORY
437+ ) ;
437438
438439 match ctl
439440 . mget_table_names_by_ids ( & tenant, & tables_ids, WITH_HISTORY )
@@ -442,7 +443,7 @@ where TablesTable<WITH_HISTORY, WITHOUT_VIEW>: HistoryAware
442443 Ok ( tables) => {
443444 for table in tables. into_iter ( ) . flatten ( ) {
444445 if !tables_names. contains ( & table) {
445- tables_names. push ( table. clone ( ) ) ;
446+ tables_names. insert ( table. clone ( ) ) ;
446447 }
447448 }
448449 }
@@ -451,6 +452,8 @@ where TablesTable<WITH_HISTORY, WITHOUT_VIEW>: HistoryAware
451452 warn ! ( "{}" , msg) ;
452453 }
453454 }
455+ println ! ( "table_ids is {:?}" , tables_ids) ;
456+ println ! ( "table_names is {:?}" , tables_names) ;
454457 }
455458 }
456459
@@ -532,6 +535,7 @@ where TablesTable<WITH_HISTORY, WITHOUT_VIEW>: HistoryAware
532535 || invalid_tables_ids
533536 || invalid_optimize
534537 {
538+ println ! ( "will call list_tables" ) ;
535539 match Self :: list_tables ( ctl, & tenant, db_name, WITH_HISTORY , WITHOUT_VIEW )
536540 . await
537541 {
0 commit comments