Skip to content

Commit 0403b24

Browse files
authored
Merge b1c9ecc into 1f60fc8
2 parents 1f60fc8 + b1c9ecc commit 0403b24

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

ydb/tests/olap/lib/ydb_cluster.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from ydb.tests.olap.lib.utils import get_external_param
99
from copy import deepcopy
1010
from time import sleep, time
11-
from typing import List, Optional
11+
from typing import List, Optional, Callable
1212
from enum import Enum
1313

1414
LOGGER = logging.getLogger()
@@ -172,17 +172,20 @@ def get_ydb_driver(cls):
172172
return cls._ydb_driver
173173

174174
@classmethod
175-
def list_directory(cls, root_path: str, rel_path: str) -> List[ydb.SchemeEntry]:
175+
def list_directory(cls, root_path: str, rel_path: str, kind_order_key: Optional[Callable[[ydb.SchemeEntryType], int]] = None) -> List[ydb.SchemeEntry]:
176176
path = f'{root_path}/{rel_path}' if root_path else rel_path
177177
LOGGER.info(f'list {path}')
178178
result = []
179-
for child in cls.get_ydb_driver().scheme_client.list_directory(path).children:
179+
entries = cls.get_ydb_driver().scheme_client.list_directory(path).children
180+
if kind_order_key is not None:
181+
entries = sorted(entries, key=lambda x: kind_order_key(x.type))
182+
for child in entries:
180183
if child.name == '.sys':
181184
continue
182185
child.name = f'{rel_path}/{child.name}'
183186
result.append(child)
184187
if child.is_directory() or child.is_column_store():
185-
result += cls.list_directory(root_path, child.name)
188+
result += cls.list_directory(root_path, child.name, kind_order_key)
186189
return result
187190

188191
@classmethod

ydb/tests/olap/scenario/helpers/scenario_tests_helper.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,20 @@ def list_path(self, path: str, folder: str) -> List[ydb.SchemeEntry]:
679679
if self_descr is None:
680680
return []
681681

682+
kind_order = [
683+
ydb.SchemeEntryType.COLUMN_TABLE,
684+
ydb.SchemeEntryType.COLUMN_STORE,
685+
ydb.SchemeEntryType.EXTERNAL_DATA_SOURCE,
686+
]
687+
688+
def kind_order_key_reversed(kind):
689+
try:
690+
return -kind_order.index(kind)
691+
except ValueError:
692+
return -len(kind_order)
693+
682694
if self_descr.is_directory():
683-
return list(reversed(YdbCluster.list_directory(root_path, path))) + [self_descr]
695+
return list(reversed(YdbCluster.list_directory(root_path, path, kind_order_key_reversed))) + [self_descr]
684696
else:
685697
return self_descr
686698

0 commit comments

Comments
 (0)