@@ -25,6 +25,7 @@ use databend_common_catalog::table::Table;
2525use databend_common_catalog:: table_context:: TableContext ;
2626use databend_common_exception:: Result ;
2727use databend_common_expression:: types:: number:: UInt64Type ;
28+ use databend_common_expression:: types:: BooleanType ;
2829use databend_common_expression:: types:: NumberDataType ;
2930use databend_common_expression:: types:: StringType ;
3031use databend_common_expression:: types:: TimestampType ;
@@ -104,6 +105,7 @@ impl<const T: bool> AsyncSystemTable for StreamsTable<T> {
104105 let mut updated_on = vec ! [ ] ;
105106 let mut table_version = vec ! [ ] ;
106107 let mut snapshot_location = vec ! [ ] ;
108+ let mut has_data = vec ! [ ] ;
107109
108110 let max_threads = ctx. get_settings ( ) . get_max_threads ( ) ? as usize ;
109111 let io_request_semaphore = Arc :: new ( Semaphore :: new ( max_threads) ) ;
@@ -235,7 +237,8 @@ impl<const T: bool> AsyncSystemTable for StreamsTable<T> {
235237 }
236238 comment. push ( stream_info. meta . comment . clone ( ) ) ;
237239
238- table_version. push ( stream_table. offset ( ) . ok ( ) ) ;
240+ let offset = stream_table. offset ( ) . ok ( ) ;
241+ table_version. push ( offset) ;
239242 table_id. push ( source_tb_id) ;
240243 snapshot_location. push ( stream_table. snapshot_loc ( ) ) ;
241244
@@ -244,6 +247,7 @@ impl<const T: bool> AsyncSystemTable for StreamsTable<T> {
244247 let table = table. clone ( ) ;
245248 let handler = runtime. spawn ( async move {
246249 let mut reason = "" . to_string ( ) ;
250+ let mut has_data = false ;
247251 // safe unwrap.
248252 let stream_table = StreamTable :: try_from_table ( table. as_ref ( ) ) . unwrap ( ) ;
249253 match stream_table. source_table ( ctx) . await {
@@ -258,23 +262,28 @@ impl<const T: bool> AsyncSystemTable for StreamsTable<T> {
258262 . err ( )
259263 . map_or ( "" . to_string ( ) , |e| e. display_text ( ) ) ;
260264 }
265+ if let Some ( ver) = offset {
266+ has_data = fuse_table. get_table_info ( ) . ident . seq != ver;
267+ }
261268 }
262269 Err ( e) => {
263270 reason = e. display_text ( ) ;
264271 }
265272 }
266273 drop ( permit) ;
267- reason
274+ ( reason, has_data )
268275 } ) ;
269276 handlers. push ( handler) ;
270277 }
271278 }
272279 }
273280
274- let mut joint = futures:: future:: try_join_all ( handlers)
281+ let joint = futures:: future:: try_join_all ( handlers)
275282 . await
276283 . unwrap_or_default ( ) ;
277- invalid_reason. append ( & mut joint) ;
284+ let ( mut reasons, mut flags) : ( Vec < String > , Vec < bool > ) = joint. into_iter ( ) . unzip ( ) ;
285+ invalid_reason. append ( & mut reasons) ;
286+ has_data. append ( & mut flags) ;
278287 }
279288
280289 let mut source_db_ids = source_db_id_set. into_iter ( ) . collect :: < Vec < u64 > > ( ) ;
@@ -328,6 +337,7 @@ impl<const T: bool> AsyncSystemTable for StreamsTable<T> {
328337 UInt64Type :: from_opt_data( table_version) ,
329338 StringType :: from_opt_data( snapshot_location) ,
330339 StringType :: from_data( invalid_reason) ,
340+ BooleanType :: from_data( has_data) ,
331341 StringType :: from_opt_data( owner) ,
332342 ] ) )
333343 } else {
@@ -375,6 +385,7 @@ impl<const T: bool> StreamsTable<T> {
375385 TableDataType :: Nullable ( Box :: new( TableDataType :: String ) ) ,
376386 ) ,
377387 TableField :: new( "invalid_reason" , TableDataType :: String ) ,
388+ TableField :: new( "has_data" , TableDataType :: Boolean ) ,
378389 TableField :: new(
379390 "owner" ,
380391 TableDataType :: Nullable ( Box :: new( TableDataType :: String ) ) ,
0 commit comments