@@ -277,7 +277,13 @@ def check_exists(self, table_path: str) -> bool:
277277 @handle_ydb_errors
278278 def get_table_names (self ) -> list [str ]:
279279 abs_dir_path = posixpath .join (self .database , self .table_path_prefix )
280- names = self ._get_table_names (abs_dir_path )
280+ names = self ._get_entity_names (abs_dir_path , ydb .SchemeEntryType .TABLE )
281+ return [posixpath .relpath (path , abs_dir_path ) for path in names ]
282+
283+ @handle_ydb_errors
284+ def get_view_names (self ) -> list [str ]:
285+ abs_dir_path = posixpath .join (self .database , self .table_path_prefix )
286+ names = self ._get_entity_names (abs_dir_path , ydb .SchemeEntryType .VIEW )
281287 return [posixpath .relpath (path , abs_dir_path ) for path in names ]
282288
283289 def _check_path_exists (self , table_path : str ) -> bool :
@@ -295,7 +301,9 @@ def callee() -> None:
295301 else :
296302 return True
297303
298- def _get_table_names (self , abs_dir_path : str ) -> list [str ]:
304+ def _get_entity_names (
305+ self , abs_dir_path : str , etype : ydb .SchemeEntryType
306+ ) -> list [str ]:
299307 settings = self ._get_request_settings ()
300308
301309 def callee () -> ydb .Directory :
@@ -308,10 +316,10 @@ def callee() -> ydb.Directory:
308316 result = []
309317 for child in directory .children :
310318 child_abs_path = posixpath .join (abs_dir_path , child .name )
311- if child .is_table () :
319+ if child .type == etype :
312320 result .append (child_abs_path )
313321 elif child .is_directory () and not child .name .startswith ("." ):
314- result .extend (self ._get_table_names (child_abs_path ))
322+ result .extend (self ._get_entity_names (child_abs_path , etype ))
315323 return result
316324
317325 @handle_ydb_errors
@@ -452,7 +460,19 @@ async def check_exists(self, table_path: str) -> bool:
452460 @handle_ydb_errors
453461 async def get_table_names (self ) -> list [str ]:
454462 abs_dir_path = posixpath .join (self .database , self .table_path_prefix )
455- names = await self ._get_table_names (abs_dir_path )
463+ names = await self ._get_entity_names (
464+ abs_dir_path ,
465+ ydb .SchemeEntryType .TABLE ,
466+ )
467+ return [posixpath .relpath (path , abs_dir_path ) for path in names ]
468+
469+ @handle_ydb_errors
470+ async def get_view_names (self ) -> list [str ]:
471+ abs_dir_path = posixpath .join (self .database , self .table_path_prefix )
472+ names = await self ._get_entity_names (
473+ abs_dir_path ,
474+ ydb .SchemeEntryType .VIEW ,
475+ )
456476 return [posixpath .relpath (path , abs_dir_path ) for path in names ]
457477
458478 async def _check_path_exists (self , table_path : str ) -> bool :
@@ -471,7 +491,9 @@ async def callee() -> None:
471491 else :
472492 return True
473493
474- async def _get_table_names (self , abs_dir_path : str ) -> list [str ]:
494+ async def _get_entity_names (
495+ self , abs_dir_path : str , etype : ydb .SchemeEntryType
496+ ) -> list [str ]:
475497 settings = self ._get_request_settings ()
476498
477499 async def callee () -> ydb .Directory :
@@ -484,10 +506,12 @@ async def callee() -> ydb.Directory:
484506 result = []
485507 for child in directory .children :
486508 child_abs_path = posixpath .join (abs_dir_path , child .name )
487- if child .is_table () :
509+ if child .type == etype :
488510 result .append (child_abs_path )
489511 elif child .is_directory () and not child .name .startswith ("." ):
490- result .extend (await self ._get_table_names (child_abs_path ))
512+ result .extend (
513+ await self ._get_entity_names (child_abs_path , etype )
514+ )
491515 return result
492516
493517 @handle_ydb_errors
0 commit comments