Repository navigation
[Python] Fix swapped session and statement IDs in query result sets - #18842
Merged
JackieTien97 merged 1 commit intoOct 13, 2026
Merged
Conversation
HTHou
approved these changes
Oct 13, 2026
JackieTien97
approved these changes
Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fix a Python client bug that swaps
sessionIdandstatementIdwhen constructing query result sets.execute_query_statement,execute_statement, andexecute_raw_data_querysend the correct IDs in the initial execution request, but pass them in reverse order toSessionDataSet. SubsequentfetchResultsV2andcloseOperationrequests therefore use the wrong IDs.execute_last_data_queryalready uses the correct order.Compatibility with newer IoTDB servers
Older Python client versions containing this bug can fail when connecting to IoTDB servers with the query ownership validation introduced by #18643. When
sessionId != statementId, the initial result batch can be returned successfully, but fetching the next batch is rejected withNO_PERMISSIONbecause the supplied statement ID does not own the query. Closing a query before all results have been consumed can also be rejected while the query is still running.If the two IDs happen to be equal, the swap is invisible. This explains why simple connections and existing tests may appear to work, while other connection/statement allocation histories expose the problem. The server validation exposes an existing client bug; users encountering this combination need a Python client containing this fix. Upgrading only the server does not correct the IDs sent by an older client.
Changes
SessionDataSetarguments by name in all four query entry points, assigning the correct connectionsession_idandstatement_idexplicitly.Validation
python3 -m pytest tests/unit -q --tb=short— 50 passed.git diff --checkpassed.This PR has:
Key changed/added classes
iotdb.Session.Sessiontests/unit/test_session_query_ids.py