| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Adds cursor.bulkcopy_arrow(table_name, source) to bulk-load directly from Apache Arrow data (pyarrow Table/RecordBatch/RecordBatchReader, __arrow_c_stream__/__arrow_c_array__ producers, or an iterable of batches) via the mssql_py_core Rust core, streaming through the Arrow C Data Interface with the GIL released during transfer. bulkcopy() now raises TypeError to steer Arrow inputs here. Auth setup is refactored into a shared _build_pycore_context() helper (preserves SQL, pre-acquired-token, and ServicePrincipal factory paths). Adds tests/test_024_bulkcopy_arrow.py (36 unit tests at 100% coverage of the new code + 16 live round-trip/type-matrix tests) and benchmarks/bench_bulkcopy_arrow.py. Requires mssql-py-core 0.1.5+.
There was a problem hiding this comment.
Adds Apache Arrow support to the Bulk Copy API by introducing a dedicated Cursor.bulkcopy_arrow() path and refactoring shared connection/auth context construction so both tuple-based and Arrow-based bulk copy use consistent handling.
Changes:
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file| File | Description |
|---|---|
| tests/test_024_bulkcopy_arrow.py | Adds unit + live-DB integration coverage for Arrow bulk copy, auth context building, and Arrow-source detection. |
| mssql_python/mssql_python.pyi | Updates public type stubs to include bulkcopy and new bulkcopy_arrow API. |
| mssql_python/cursor.py | Implements _build_pycore_context, Arrow source detection/steering, and the new bulkcopy_arrow method. |
| CHANGELOG.md | Documents the new Arrow bulk copy feature and related requirements/behavior changes. |
| benchmarks/bench_bulkcopy_arrow.py | Adds a benchmark script comparing tuple-based vs Arrow-based bulk copy performance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
…sign D13) Remove the keyword-only '*' from Cursor.bulkcopy_arrow (cursor.py + stub) so batch_size/timeout match bulkcopy's signature per the finalized design (D13/section 2). Also set cursor._timeout in the test mock-cursor helper (main's #650 added self._timeout to the shared _build_pycore_context) and add a positional-args regression test.
…al (List[str]) semantics
…w_c_array__); use non-localhost host in unit-test conn strings
…s, memory, MB/s, CSV)
…oney/xml/legacy-datetime/date64/fixed-binary
# Conflicts: # tests/test_019_bulkcopy.py
📊 Code Coverage Report
Diff CoverageDiff: main...HEAD, staged and unstaged changes
Summary
📋 Files Needing Attention📉 Files with overall lowest coverage (click to expand)mssql_python.pybind.logger_bridge.cpp: 59.2%
mssql_python.pybind.ddbc_bindings.h: 59.9%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.pybind.ddbc_bindings.cpp: 76.2%
mssql_python.__init__.py: 77.3%
mssql_python.row.py: 77.6%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.pybind.connection.connection_pool.cpp: 82.7%
mssql_python.pybind.connection.connection.cpp: 83.7%
mssql_python.connection.py: 84.7%🔗 Quick Links
|
Sorry, something went wrong.
There was a problem hiding this comment.
no major problems or blockers found - just some improvements to code structure and a nit miss on error message, will approve once done
Sorry, something went wrong.
…uard str/bytes source, consistent bare re-raise
After merging the Arrow bulk copy feature (#665), _build_pycore_context now reads self.connection._token_provider before the _auth_type dispatch. The test_024 _cursor_with_conn helper builds a bare MagicMock connection, which auto-vivifies a truthy _token_provider and routed every case through the custom-credential token path -> InterfaceError (12 failures in CI). Real Connection objects always initialize _token_provider to None; set it explicitly on the mock so it is faithful.
| @@ -1 +1 @@ | |||
| 0.1.7 No newline at end of file | |||
| 0.1.8-dev.20260729.163613 No newline at end of file | |||
There was a problem hiding this comment.
gargsaumya Please be aware that the release on top of a dev/nightly build of py-core is going to fail. There are checks in the pipeline to prevent such a thing from happening :)
Please create a release of mssql-py-core (now that you have tested with a dev build), and change the version in this file to 0.1.8
Sorry, something went wrong.
### Work Item / Issue Reference > [AB#47087](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/47087) ------------------------------------------------------------------- ### Summary Release mssql-python v1.13.0. Version bump to 1.13.0. Updates `mssql_python/__init__.py`, `setup.py`, `PyPI_Description.md`, and the README "Important Note" section. Bundled `mssql_py_core` bumped from 0.1.7 to 0.1.8 (no source/API changes — dev-nightly to stable pin). #### Enhancements - **ODBC driver ships exclusively via `mssql-python-odbc` (Phase 2)** — The `libs/` fallback introduced in v1.12.0 has been removed. `mssql-python` now hard-depends on `mssql-python-odbc==18.6.2.1`; `pip install mssql-python` still pulls the driver package transparently. Smaller wheels; driver binaries managed independently (#693). - **Apache Arrow bulk copy** — New `Cursor.bulkcopy_arrow(table_name, source)` method for high-performance bulk loading from `pyarrow.Table` / `RecordBatch` / Arrow C Data Interface sources; classic `bulkcopy()` now raises `TypeError` for Arrow inputs and steers users to the new method (#665). - **`token_provider=` parameter for Azure Identity credentials** — `connect()` accepts any credential with a `.get_token(scope)` method (`DefaultAzureCredential`, `AzureCliCredential`, `ManagedIdentityCredential`, …). Mutually exclusive with `Authentication=` in the connection string (#603, issue #577). - **Identity-aware connection pooling with token-expiry refresh** — Pool now keys on security context, preventing cross-identity connection leaks; token acquisition deferred to pool-misses; connections with near-expiry tokens refreshed automatically (#660, issues #651, #659). #### Bug Fixes - **Silent zero-row `executemany` batches on late NULLs** — Fixed numeric array parameter binding paths (`TINYINT`/`SMALLINT`/`INT`/`FLOAT`) that left indicator slots uninitialized when a NULL appeared partway through the batch (#702, issue #670). - **`SQL_WVARCHAR` output converter applied as catch-all to non-string columns** — Fallback now gated on `str`/`bytes` mapped types (#692, issue #691). - **Integer-keyed output converters silently never fired** — `add_output_converter(SQL_DECIMAL, ...)` and other integer SQL type code keys now dispatch correctly (pyodbc parity) (#690, issue #684). - **`RecordBatchReader.Close()` for Arrow result sets** — `Cursor.arrow_reader()` now returns a wrapper whose `.close()` releases server-side resources and leaves the parent cursor usable (#644, issue #643). - **`AttributeError` in `Cursor.__del__` on partially-initialized cursor** — `__init__` sets `closed`/`hstmt` before any raise; `__del__` uses correct `sys.is_finalizing()` guard (#646, issue #642). #### Version Bump - `mssql_python/__init__.py`: `__version__ = "1.13.0"` - `setup.py`: `version="1.13.0"` - `PyPI_Description.md`: `## What's new in v1.13.0` section refreshed - `README.md`: "Important Note" updated for Phase 2 (no more `libs/` fallback, `mssql-python-odbc==18.6.2.1`)
resolves the cursor.py conflict from #665, which moved the shared bulkcopy validation into _bulkcopy_core_and_validate. the timeout fix now lives in that single helper, so it covers bulkcopy and bulkcopy_arrow at once. also updates test_024's timeout_non_positive, which asserted the old behaviour, and adds _token_provider to the new mock cursor for the #603 token_provider path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
Work Item / Issue Reference
Summary
This pull request introduces a new high-performance bulkcopy_arrow method to the Cursor class for bulk loading data directly from Apache Arrow sources, along with several related improvements and refactorings. It also updates type stubs and documentation to reflect the new API, and improves bulk copy authentication handling by refactoring shared logic.
New feature: Arrow-based bulk copy
Codebase refactoring and improvements
Documentation
Minor improvements