-
Notifications
You must be signed in to change notification settings - Fork 24
FEAT: Streaming support in fetchone, fetchmany, fetchall for varbinarymax data type. #232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoiding repeated comments from other PRs, just added some minor changes here
I believe this PR will merge at last since other changes will merge here
The base branch was changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor fixes are required.
4e5cfe8
to
2ea9862
Compare
There was a problem hiding this comment.
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 adds streaming support for VARBINARY(MAX) data types in the fetchone, fetchmany, and fetchall operations, significantly improving the driver's ability to handle large binary data. The changes enable proper insertion and retrieval of binary data larger than 8000 bytes, which previously had limitations.
- Implemented chunked streaming retrieval for large binary columns (LOBs) using a new
FetchLobColumnData
helper function - Enhanced parameter binding to support Data-At-Execution (DAE) for large binary parameters
- Updated fetch operations to detect LOB columns and use appropriate streaming vs buffered approaches
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
mssql_python/pybind/ddbc_bindings.cpp | Core implementation of LOB streaming support, DAE parameter binding, and enhanced fetch operations |
mssql_python/cursor.py | Updated parameter mapping to use VARBINARY(MAX) with DAE for large binary data |
tests/test_004_cursor.py | Replaced limited test with comprehensive VARBINARY(MAX) tests covering various data sizes and fetch methods |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
2ea9862
to
85a4487
Compare
…com/microsoft/mssql-python into saumya/streaming-varbinarymax-fetch
7cee625
to
e50de23
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good.
Work Item / Issue Reference
Summary
This pull request significantly improves support for streaming and fetching large binary (VARBINARY(MAX)) and large text columns in the MSSQL Python driver. The main changes include robust chunked retrieval of large objects (LOBs), correct handling of edge cases (such as empty or null values), and enhanced test coverage for these scenarios.
LOB Streaming and Fetching Enhancements:
FetchLobColumnData
to efficiently stream and assemble large binary/text columns (LOBs) from the database, handling chunking, null/empty values, and correct type conversion for both binary and (wide/narrow) string columns.SQLGetData_wrap
,FetchBatchData
,FetchMany_wrap
, andFetchAll_wrap
to detect LOB columns and use the new streaming path for fetching them, including proper fallback to row-by-row fetching when LOBs are present. [1] [2] [3] [4] [5] [6]Testing Improvements:
test_varbinarymax_insert_fetch
) that verifies insertion and retrieval of empty, small, and large VARBINARY(MAX) values (including edge cases around the 8000-byte threshold) usingfetchone
,fetchall
, andfetchmany
.These changes ensure that the driver can reliably handle large binary and text columns in all fetch scenarios, improving correctness and robustness for users working with LOB data.