From caf04680622724bbd6ba035be9e88b6e6029f7bd Mon Sep 17 00:00:00 2001 From: Timofey Koolin Date: Thu, 23 Nov 2023 12:28:54 +0300 Subject: [PATCH] - Added YDB convert support EmptyDict, EmptyList types - Added EXTERNAL_ERROR status code and issue ExternalError --- CHANGELOG.md | 3 +++ ydb/_tx_ctx_impl.py | 1 + ydb/convert.py | 2 ++ ydb/issues.py | 6 ++++++ 4 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d77a87fe..10586476 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +* Added YDB convert support EmptyDict, EmptyList types +* Added EXTERNAL_ERROR status code and issue ExternalError + ## 2.13.4 ## * Fixed set keep_in_cache algorithm diff --git a/ydb/_tx_ctx_impl.py b/ydb/_tx_ctx_impl.py index 2c7db63c..925d74b4 100644 --- a/ydb/_tx_ctx_impl.py +++ b/ydb/_tx_ctx_impl.py @@ -152,6 +152,7 @@ def execute_request_factory( if keep_in_cache: request.query_cache_policy.keep_in_cache = True + request.query.MergeFrom(query_pb) tx_control = _apis.ydb_table.TransactionControl() tx_control.commit_tx = commit_tx diff --git a/ydb/convert.py b/ydb/convert.py index b231bb10..97d51cf1 100644 --- a/ydb/convert.py +++ b/ydb/convert.py @@ -125,6 +125,8 @@ def _pb_to_void(type_pb, value_pb, table_client_settings): "dict_type": _pb_to_dict, "struct_type": _pb_to_struct, "void_type": _pb_to_void, + "empty_list_type": _pb_to_list, + "empty_dict_type": _pb_to_dict, } diff --git a/ydb/issues.py b/ydb/issues.py index 2e128d5a..05e0db56 100644 --- a/ydb/issues.py +++ b/ydb/issues.py @@ -32,6 +32,7 @@ class StatusCode(enum.IntEnum): UNDETERMINED = _apis.StatusIds.UNDETERMINED UNSUPPORTED = _apis.StatusIds.UNSUPPORTED SESSION_BUSY = _apis.StatusIds.SESSION_BUSY + EXTERNAL_ERROR = _apis.StatusIds.EXTERNAL_ERROR CONNECTION_LOST = _TRANSPORT_STATUSES_FIRST + 10 CONNECTION_FAILURE = _TRANSPORT_STATUSES_FIRST + 20 @@ -152,6 +153,10 @@ class SessionBusy(Error): status = StatusCode.SESSION_BUSY +class ExternalError(Error): + status = StatusCode.EXTERNAL_ERROR + + class SessionPoolEmpty(Error, queue.Empty): status = StatusCode.SESSION_POOL_EMPTY @@ -191,6 +196,7 @@ def _format_response(response): StatusCode.UNDETERMINED: Undetermined, StatusCode.UNSUPPORTED: Unsupported, StatusCode.SESSION_BUSY: SessionBusy, + StatusCode.EXTERNAL_ERROR: ExternalError, }