3
3
import time
4
4
import typing
5
5
6
+ from typing import (
7
+ Any ,
8
+ Dict ,
9
+ List ,
10
+ Optional ,
11
+ Tuple ,
12
+ )
13
+
6
14
import ydb
7
15
8
16
from ydb import issues , settings as settings_impl , table
@@ -172,16 +180,16 @@ async def create_table(
172
180
self ,
173
181
path : str ,
174
182
table_description : TableDescription ,
175
- settings : typing . Optional [settings_impl .BaseRequestSettings ] = None ,
176
- ):
183
+ settings : Optional [settings_impl .BaseRequestSettings ] = None ,
184
+ ) -> ydb . Operation :
177
185
"""
178
186
Create a YDB table.
179
187
180
188
:param path: A table path
181
- :param table_description: A description of table to create. An instance TableDescription
182
- :param settings: An instance of BaseRequestSettings that describes how rpc should invoked.
189
+ :param table_description: TableDescription instanse.
190
+ :param settings: An instance of BaseRequestSettings that describes how rpc should be invoked.
183
191
184
- :return: A description of created scheme entry or error otherwise.
192
+ :return: Operation or YDB error otherwise.
185
193
"""
186
194
187
195
async def callee (session : Session ):
@@ -192,32 +200,63 @@ async def callee(session: Session):
192
200
async def drop_table (
193
201
self ,
194
202
path : str ,
195
- settings : typing .Optional [settings_impl .BaseRequestSettings ] = None ,
196
- ):
203
+ settings : Optional [settings_impl .BaseRequestSettings ] = None ,
204
+ ) -> ydb .Operation :
205
+ """
206
+ Drop a YDB table.
207
+
208
+ :param path: A table path
209
+ :param settings: An instance of BaseRequestSettings that describes how rpc should be invoked.
210
+
211
+ :return: Operation or YDB error otherwise.
212
+ """
213
+
197
214
async def callee (session : Session ):
198
215
return await session .drop_table (path = path , settings = settings )
199
216
200
217
return await self ._pool .retry_operation (callee )
201
218
202
219
async def alter_table (
203
220
self ,
204
- path ,
205
- add_columns = None ,
206
- drop_columns = None ,
207
- settings = None ,
208
- alter_attributes = None ,
209
- add_indexes = None ,
210
- drop_indexes = None ,
211
- set_ttl_settings = None ,
212
- drop_ttl_settings = None ,
213
- add_column_families = None ,
214
- alter_column_families = None ,
215
- alter_storage_settings = None ,
216
- set_compaction_policy = None ,
217
- alter_partitioning_settings = None ,
218
- set_key_bloom_filter = None ,
219
- set_read_replicas_settings = None ,
220
- ):
221
+ path : str ,
222
+ add_columns : Optional [List [ydb .Column ]] = None ,
223
+ drop_columns : Optional [List [str ]] = None ,
224
+ settings : Optional [settings_impl .BaseRequestSettings ] = None ,
225
+ alter_attributes : Optional [Optional [Dict [str , str ]]] = None ,
226
+ add_indexes : Optional [List [ydb .TableIndex ]] = None ,
227
+ drop_indexes : Optional [List [str ]] = None ,
228
+ set_ttl_settings : Optional [ydb .TtlSettings ] = None ,
229
+ drop_ttl_settings : Optional [Any ] = None ,
230
+ add_column_families : Optional [List [ydb .ColumnFamily ]] = None ,
231
+ alter_column_families : Optional [List [ydb .ColumnFamily ]] = None ,
232
+ alter_storage_settings : Optional [ydb .StorageSettings ] = None ,
233
+ set_compaction_policy : Optional [str ] = None ,
234
+ alter_partitioning_settings : Optional [ydb .PartitioningSettings ] = None ,
235
+ set_key_bloom_filter : Optional [ydb .FeatureFlag ] = None ,
236
+ set_read_replicas_settings : Optional [ydb .ReadReplicasSettings ] = None ,
237
+ ) -> ydb .Operation :
238
+ """
239
+ Alter a YDB table.
240
+
241
+ :param path: A table path
242
+ :param add_columns: List of ydb.Column to add
243
+ :param drop_columns: List of column names to drop
244
+ :param settings: An instance of BaseRequestSettings that describes how rpc should be invoked.
245
+ :param alter_attributes: Dict of attributes to alter
246
+ :param add_indexes: List of ydb.TableIndex to add
247
+ :param drop_indexes: List of index names to drop
248
+ :param set_ttl_settings: ydb.TtlSettings to set
249
+ :param drop_ttl_settings: Any to drop
250
+ :param add_column_families: List of ydb.ColumnFamily to add
251
+ :param alter_column_families: List of ydb.ColumnFamily to alter
252
+ :param alter_storage_settings: ydb.StorageSettings to alter
253
+ :param set_compaction_policy: Compaction policy
254
+ :param alter_partitioning_settings: ydb.PartitioningSettings to alter
255
+ :param set_key_bloom_filter: ydb.FeatureFlag to set key bloom filter
256
+
257
+ :return: Operation or YDB error otherwise.
258
+ """
259
+
221
260
async def callee (session : Session ):
222
261
return await session .alter_table (
223
262
path = path ,
@@ -240,13 +279,41 @@ async def callee(session: Session):
240
279
241
280
return await self ._pool .retry_operation (callee )
242
281
243
- async def describe_table (self , path , settings = None ):
282
+ async def describe_table (
283
+ self ,
284
+ path : str ,
285
+ settings : Optional [settings_impl .BaseRequestSettings ] = None ,
286
+ ) -> ydb .TableSchemeEntry :
287
+ """
288
+ Describe a YDB table.
289
+
290
+ :param path: A table path
291
+ :param settings: An instance of BaseRequestSettings that describes how rpc should be invoked.
292
+
293
+ :return: TableSchemeEntry or YDB error otherwise.
294
+ """
295
+
244
296
async def callee (session : Session ):
245
297
return await session .describe_table (path = path , settings = settings )
246
298
247
299
return await self ._pool .retry_operation (callee )
248
300
249
- async def copy_table (self , source_path , destination_path , settings = None ):
301
+ async def copy_table (
302
+ self ,
303
+ source_path : str ,
304
+ destination_path : str ,
305
+ settings : Optional [settings_impl .BaseRequestSettings ] = None ,
306
+ ) -> ydb .Operation :
307
+ """
308
+ Copy a YDB table.
309
+
310
+ :param source_path: A table path
311
+ :param destination_path: Destination table path
312
+ :param settings: An instance of BaseRequestSettings that describes how rpc should be invoked.
313
+
314
+ :return: Operation or YDB error otherwise.
315
+ """
316
+
250
317
async def callee (session : Session ):
251
318
return await session .copy_table (
252
319
source_path = source_path ,
@@ -256,13 +323,39 @@ async def callee(session: Session):
256
323
257
324
return await self ._pool .retry_operation (callee )
258
325
259
- async def copy_tables (self , source_destination_pairs , settings = None ):
326
+ async def copy_tables (
327
+ self ,
328
+ source_destination_pairs : List [Tuple [str , str ]],
329
+ settings : Optional [settings_impl .BaseRequestSettings ] = None
330
+ ) -> ydb .Operation :
331
+ """
332
+ Copy a YDB tables.
333
+
334
+ :param source_destination_pairs: List of tuples (source_path, destination_path)
335
+ :param settings: An instance of BaseRequestSettings that describes how rpc should be invoked.
336
+
337
+ :return: Operation or YDB error otherwise.
338
+ """
339
+
260
340
async def callee (session : Session ):
261
341
return await session .copy_tables (source_destination_pairs = source_destination_pairs , settings = settings )
262
342
263
343
return await self ._pool .retry_operation (callee )
264
344
265
- async def rename_tables (self , rename_items , settings = None ):
345
+ async def rename_tables (
346
+ self ,
347
+ rename_items : List [Tuple [str , str ]],
348
+ settings = None
349
+ ) -> ydb .Operation :
350
+ """
351
+ Rename a YDB tables.
352
+
353
+ :param rename_items: List of tuples (current_name, desired_name)
354
+ :param settings: An instance of BaseRequestSettings that describes how rpc should be invoked.
355
+
356
+ :return: Operation or YDB error otherwise.
357
+ """
358
+
266
359
async def callee (session : Session ):
267
360
return await session .rename_tables (rename_items = rename_items , settings = settings )
268
361
0 commit comments