@@ -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,7 @@ 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 (self , abs_dir_path : str , etype : int ) -> list [str ]:
299305 settings = self ._get_request_settings ()
300306
301307 def callee () -> ydb .Directory :
@@ -308,10 +314,10 @@ def callee() -> ydb.Directory:
308314 result = []
309315 for child in directory .children :
310316 child_abs_path = posixpath .join (abs_dir_path , child .name )
311- if child .is_table () :
317+ if child .type == etype :
312318 result .append (child_abs_path )
313319 elif child .is_directory () and not child .name .startswith ("." ):
314- result .extend (self ._get_table_names (child_abs_path ))
320+ result .extend (self ._get_entity_names (child_abs_path , etype ))
315321 return result
316322
317323 @handle_ydb_errors
@@ -452,7 +458,19 @@ async def check_exists(self, table_path: str) -> bool:
452458 @handle_ydb_errors
453459 async def get_table_names (self ) -> list [str ]:
454460 abs_dir_path = posixpath .join (self .database , self .table_path_prefix )
455- names = await self ._get_table_names (abs_dir_path )
461+ names = await self ._get_entity_names (
462+ abs_dir_path ,
463+ ydb .SchemeEntryType .TABLE ,
464+ )
465+ return [posixpath .relpath (path , abs_dir_path ) for path in names ]
466+
467+ @handle_ydb_errors
468+ async def get_view_names (self ) -> list [str ]:
469+ abs_dir_path = posixpath .join (self .database , self .table_path_prefix )
470+ names = await self ._get_entity_names (
471+ abs_dir_path ,
472+ ydb .SchemeEntryType .VIEW ,
473+ )
456474 return [posixpath .relpath (path , abs_dir_path ) for path in names ]
457475
458476 async def _check_path_exists (self , table_path : str ) -> bool :
@@ -471,7 +489,9 @@ async def callee() -> None:
471489 else :
472490 return True
473491
474- async def _get_table_names (self , abs_dir_path : str ) -> list [str ]:
492+ async def _get_entity_names (
493+ self , abs_dir_path : str , etype : int
494+ ) -> list [str ]:
475495 settings = self ._get_request_settings ()
476496
477497 async def callee () -> ydb .Directory :
@@ -484,10 +504,12 @@ async def callee() -> ydb.Directory:
484504 result = []
485505 for child in directory .children :
486506 child_abs_path = posixpath .join (abs_dir_path , child .name )
487- if child .is_table () :
507+ if child .type == etype :
488508 result .append (child_abs_path )
489509 elif child .is_directory () and not child .name .startswith ("." ):
490- result .extend (await self ._get_table_names (child_abs_path ))
510+ result .extend (
511+ await self ._get_entity_names (child_abs_path , etype )
512+ )
491513 return result
492514
493515 @handle_ydb_errors
0 commit comments