Skip to content

Merge streamed result set parts in execute_with_retries#862

Open
vgvoleg wants to merge 5 commits into
mainfrom
execute-with-retries-merge-result-sets
Open

Merge streamed result set parts in execute_with_retries#862
vgvoleg wants to merge 5 commits into
mainfrom
execute-with-retries-merge-result-sets

Conversation

@vgvoleg

@vgvoleg vgvoleg commented Jul 17, 2026

Copy link
Copy Markdown
Member

execute_with_retries materializes the query stream, but the query service splits one logical result set into several stream parts that share a result_set_index. Those parts were returned as separate ResultSet objects, so a large SELECT came back as multiple result sets instead of one.

Parts sharing an index are now concatenated back into a single result set — rows and arrow data are joined, the schema is taken from the first part. A query now yields one result set per SELECT regardless of its size.

Closes: #863

Stream parts that share a result_set_index are concatenated back into a
single ResultSet, so execute_with_retries returns one result set per
SELECT regardless of its size instead of one per stream part.
@vgvoleg
vgvoleg requested a review from Copilot July 17, 2026 14:04
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.20%. Comparing base (3bcd540) to head (3df0666).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #862      +/-   ##
==========================================
+ Coverage   82.18%   82.20%   +0.02%     
==========================================
  Files          99       99              
  Lines       12683    12703      +20     
  Branches     1235     1240       +5     
==========================================
+ Hits        10423    10443      +20     
  Misses       1804     1804              
  Partials      456      456              
Flag Coverage Δ
integration 80.07% <68.18%> (+<0.01%) ⬆️
unit 47.23% <90.90%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
ydb/aio/query/pool.py 94.63% <100.00%> (ø)
ydb/convert.py 86.57% <100.00%> (+0.74%) ⬆️
ydb/query/pool.py 92.45% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes QuerySessionPool.execute_with_retries (sync + async) returning multiple ResultSet objects for a single logical SELECT when the Query service splits one result set across multiple streamed response parts sharing the same result_set_index. It introduces a utility to merge those parts back into one result set per index.

Changes:

  • Aggregate streamed ResultSet parts by result_set_index in execute_with_retries (sync and async).
  • Add aggregate_result_sets_by_index in ydb.convert and unit tests for its merging behavior (rows, schema, truncated, Arrow data).
  • Add integration tests validating large SELECT results are returned as a single merged result set; document the fix in CHANGELOG.md.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ydb/query/pool.py Uses result-set aggregation in sync execute_with_retries.
ydb/aio/query/pool.py Uses result-set aggregation in async execute_with_retries.
ydb/convert.py Adds aggregate_result_sets_by_index to merge streamed parts sharing an index.
ydb/query/pool_test.py Adds unit tests validating aggregation semantics (rows/schema/truncation/data).
tests/query/test_query_session_pool.py Adds integration test ensuring large result sets are merged for sync pool.
tests/aio/query/test_query_session_pool.py Adds integration test ensuring large result sets are merged for async pool.
CHANGELOG.md Adds user-facing changelog entry for the fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ydb/convert.py

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread ydb/convert.py Outdated
Comment on lines +418 to +426
self.rows.extend(other.rows)
if other.truncated:
self.truncated = True
if not self.columns and other.columns:
self.columns = other.columns
if other.data is not None:
if self._data_chunks is None:
self._data_chunks = [self.data] if self.data is not None else []
self._data_chunks.append(other.data)
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.

Additional result sets from python sdk

2 participants