diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b23dca4..8fb39ca1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +* Include streaming queries in scheme directory listings and path descriptions * Add timeout to the token exchange request so a stalled token endpoint cannot hang credential refresh * Fix topic reader `close()` hanging forever when the stream is broken with uncommitted offsets pending: the commit flush now stops as soon as the stream reports an error instead of waiting for acks that can never arrive * Fix async table session pool capacity leaking when keeping an idle session alive fails or is cancelled diff --git a/docs/scheme.rst b/docs/scheme.rst index df9264ff..327e9b84 100644 --- a/docs/scheme.rst +++ b/docs/scheme.rst @@ -140,6 +140,7 @@ Every scheme object is described by a :class:`~ydb.SchemeEntry`: entry.is_coordination_node() # COORDINATION_NODE entry.is_external_table() # EXTERNAL_TABLE entry.is_external_data_source() # EXTERNAL_DATA_SOURCE + entry.is_streaming_query() # STREAMING_QUERY entry.is_view() # VIEW entry.is_resource_pool() # RESOURCE_POOL entry.is_sysview() # SYS_VIEW @@ -180,6 +181,8 @@ Every scheme object is described by a :class:`~ydb.SchemeEntry`: - Async replication object * - ``SchemeEntryType.TRANSFER`` - Data transfer object + * - ``SchemeEntryType.STREAMING_QUERY`` + - Streaming query * - ``SchemeEntryType.RESOURCE_POOL`` - Resource pool (workload management) * - ``SchemeEntryType.SYS_VIEW`` diff --git a/ydb/scheme.py b/ydb/scheme.py index fd0630f8..eff35695 100644 --- a/ydb/scheme.py +++ b/ydb/scheme.py @@ -37,6 +37,7 @@ class SchemeEntryType(enum.IntEnum): TRANSFER = 23 SYS_VIEW = 24 SECRET = 25 + STREAMING_QUERY = 26 @classmethod def _missing_(cls, value): @@ -172,6 +173,14 @@ def is_secret(entry): """ return entry == SchemeEntryType.SECRET + @staticmethod + def is_streaming_query(entry): + """ + :param entry: A scheme entry to check + :return: True if scheme entry is a streaming query and False otherwise + """ + return entry == SchemeEntryType.STREAMING_QUERY + class SchemeEntry(object): __slots__ = ( @@ -304,6 +313,12 @@ def is_secret(self): """ return SchemeEntryType.is_secret(self.type) + def is_streaming_query(self): + """ + :return: True if scheme entry is a streaming query and False otherwise + """ + return SchemeEntryType.is_streaming_query(self.type) + class Directory(SchemeEntry): __slots__ = ("children",) diff --git a/ydb/scheme_test.py b/ydb/scheme_test.py index 526d2f11..cf5828cb 100644 --- a/ydb/scheme_test.py +++ b/ydb/scheme_test.py @@ -1,5 +1,6 @@ from .scheme import ( SchemeEntryType, + _wrap_describe_path_response, _wrap_scheme_entry, _wrap_list_directory_response, ) @@ -49,3 +50,31 @@ def test_wrap_list_directory_response_interrupt_permission_inheritance(): d = _wrap_list_directory_response(None, response) assert d.interrupt_permission_inheritance assert [child.interrupt_permission_inheritance for child in d.children] == [True, False] + + +def test_streaming_query_directory_and_description(): + result = ydb_scheme.ListDirectoryResult() + result.children.add(name="stream", type=26) + result.children.add(name="table", type=2) + result.children.add(name="unknown", type=1001) + response = ydb_scheme.ListDirectoryResponse() + response.operation.result.Pack(result) + + directory = _wrap_list_directory_response(None, response) + assert [child.name for child in directory.children] == ["stream", "table"] + stream, table = directory.children + assert stream.type is SchemeEntryType.STREAMING_QUERY + assert stream.is_streaming_query() + assert SchemeEntryType.is_streaming_query(stream.type) + assert not table.is_streaming_query() + + description = ydb_scheme.DescribePathResult() + description.self.name = "stream" + description.self.type = 26 + describe_response = ydb_scheme.DescribePathResponse() + describe_response.operation.result.Pack(description) + assert _wrap_describe_path_response(None, describe_response).type is SchemeEntryType.STREAMING_QUERY + + description.self.type = 1001 + describe_response.operation.result.Pack(description) + assert _wrap_describe_path_response(None, describe_response).type is SchemeEntryType.TYPE_UNSPECIFIED