Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions docs/scheme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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``
Expand Down
15 changes: 15 additions & 0 deletions ydb/scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class SchemeEntryType(enum.IntEnum):
TRANSFER = 23
SYS_VIEW = 24
SECRET = 25
STREAMING_QUERY = 26

@classmethod
def _missing_(cls, value):
Expand Down Expand Up @@ -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__ = (
Expand Down Expand Up @@ -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",)
Expand Down
29 changes: 29 additions & 0 deletions ydb/scheme_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .scheme import (
SchemeEntryType,
_wrap_describe_path_response,
_wrap_scheme_entry,
_wrap_list_directory_response,
)
Expand Down Expand Up @@ -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
Loading