Skip to content

Add TableClient.read_rows for non-transactional primary-key reads - #1

Closed
zinal wants to merge 3 commits into
mainfrom
cursor/table-client-read-rows-f0ab
Closed

zinal wants to merge 3 commits into
mainfrom
cursor/table-client-read-rows-f0ab

Conversation

@zinal

@zinal zinal commented Sep 14, 2026 •

Copy link
Copy Markdown
Owner

Pull request type

  • Feature

What is the current behavior?

The Table Service gRPC API already exposes ReadRows (read specified keys non-transactionally from a single table), and other language SDKs wrap it on TableClient. The Python SDK generated the protobuf stubs but did not provide a public client method, so callers had to use SELECT or read_table.

Issue Number: N/A

What is the new behavior?

Adds TableClient.read_rows (sync and async, plus async_read_rows on the sync client) as a session-less unary call, following the same pattern as bulk_upsert:

key_types = ydb.BulkUpsertColumns().add_column("id", ydb.PrimitiveType.Uint64)
result_set = driver.table_client.read_rows(
    "/local/users",
    [{"id": 1}, {"id": 2}],
    key_types,
    columns=("id", "name"),
)
for row in result_set.rows:
    print(row.id, row.name)
  • Missing keys are omitted from the result rather than raising an error
  • columns is optional; omit it to return every column
  • Unit tests cover request construction, response wrapping, and both the sync __call__ and async_read_rows client paths
  • Integration tests in tests/table/test_table_client.py and tests/aio/test_table_client.py exercise create/upsert/read/column projection/missing table, matching other TableClient methods

Other information

This is a public API extension only; existing methods are unchanged.

Checked locally: tox -e black, tox -e style, tox -e mypy, tox -e py -- ydb -v (223 passed), and sphinx-build -b html docs docs/_build/html -q (no new errors). Docker was not available in this environment, so the new integration tests were not executed against a live YDB.

Open in Web Open in Cursor 

cursoragent and others added 3 commits September 14, 2026 09:49
Expose the TableService ReadRows RPC on sync and async TableClient,
mirroring bulk_upsert: a session-less unary call that takes key
structures and optional column names and returns a ResultSet.

Co-authored-by: Maksim Zinal <zinal@ydb.tech>
BaseTableClient is shared by the async client, so the driver call may
return a coroutine. Annotate the result as Any, matching bulk_upsert.

Co-authored-by: Maksim Zinal <zinal@ydb.tech>
The async path was already mocked through driver.future; add the same
coverage for the unary __call__ used by the synchronous client.

Co-authored-by: Maksim Zinal <zinal@ydb.tech>
@zinal

zinal commented Sep 14, 2026

Copy link
Copy Markdown
Owner Author

Actual PR here: ydb-platform#898

@zinal zinal closed this Sep 14, 2026
@zinal
zinal deleted the cursor/table-client-read-rows-f0ab branch September 14, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants