Skip to content

FEAT: Add JSON Arrow fetching and release-gated bulk input - #928

Draft
Jahnvi Thakkar (jahnvi480) wants to merge 3 commits into
mainfrom
jahnvi/json-bulk-python-integration
Draft

Jahnvi Thakkar (jahnvi480) wants to merge 3 commits into
mainfrom
jahnvi/json-bulk-python-integration

Conversation

@jahnvi480

@jahnvi480 Jahnvi Thakkar (jahnvi480) commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Work Item / Issue Reference

Not applicable; GitHub issue referenced below.

GitHub Issue: #261 (related work; does not close the issue)


Summary

Add native JSON Arrow fetching as large_string() text and prepare lazy, mapped Json bulk-copy adaptation for the merged Rust contract.

  • Stream native JSON through the UTF-16 LOB path, including small reported column sizes; preserve SQL NULL, schema-only and empty results, and independence from json_output.
  • Adapt only mapped Json snapshots to the internal carrier without parsing, reserializing, look-ahead, or replay. Preserve legacy cells, vector rejection, and exact old-core diagnostic translation.
  • Require PyArrow >=21.0.0 in the Arrow extra and document canonical JSON input, schema checks, and transaction boundaries.
  • Add wrapper, native Arrow, producer-failure, persisted-batch, and JSON integration tests.
  • Correct the mixed snapshot/legacy-cell test: permit and count serialization of the legitimate legacy dictionary while still rejecting parsing or reserialization of the typed JSON snapshot.

Remaining release gates: The committed Rust pin remains mssql-python-rs==0.5.0; the typed JSON bulk bridge remains disabled until a published runtime containing both the carrier and fail-fast source handling is qualified and pinned. The combined source builds have now passed real native-JSON integration on Windows and Linux against SQL Server 2025. This used a development-only JSON-capable ODBC preview, not qualification of the shipped provider or a production redistributable. macOS source-build qualification was not run. No full-suite or complete OS/Python/architecture matrix qualification is claimed.

Validation

Performance investigation: CI slowdown not yet explained

CI build 196138 reported a +35.3% median paired latency increase for ASCII-medium text fetchall on SQL Server 2022. Two local base/PR comparisons did not reproduce a consistent regression, but do not establish zero regression or explain the original CI result. No speculative performance fix was committed; production code, benchmark workloads and reporting thresholds remain unchanged.

Compared base df875895484e9219753bb5bdce9f62cfb462692b with head f1964e3d70662a18ab5d8f170523fc460f0c590f. GitHub confirmed the CI candidate merge f8ebe38c24abf345589e14853f768706fc544002 has exactly the same tree as that head. Each revision used separate Release (-O3 -DNDEBUG) builds with native profiling both enabled and compiled out. Fresh processes verified their source/native import paths and profiling mode. Both sides used the identical shipped ODBC 18.6.2.2 library, not the JSON development preview.

Used the existing text_conversion_fetchall workloads unchanged: eight text columns, 5,000 rows for short/medium payloads and 200 rows for full-width payloads, with stored-byte and every-value correctness checks. Timed only public fetchall, including row wrapping; setup, query execution, validation and cleanup were excluded. Discarded one warmup pair per mode and alternated base/head order. There were no competing builds during measurement.

Workload Debian 12 / Python 3.13.15 / GCC 12.2 release, 5 pairs Ubuntu 24.04 / Python 3.12.3 / GCC 13.3 release, 10 pairs Ubuntu profiled, 10 pairs
ASCII medium (CI flagged) -0.13% +6.63% -10.54%
UTF8 medium +0.85% -0.50% +16.32%
CP1252 full -5.75% +2.59% -9.85%
CP1252 medium -0.46% +5.64% -3.86%
NVARCHAR medium -16.72% -4.22% -2.00%
ASCII short -8.15% +5.16% -2.48%

Values are median paired percentage changes in latency; positive means slower. These are not ratios of marginal medians. No local case meets the existing consistent-regression reporting criterion. Dispersion is substantial: Ubuntu release ASCII-medium base median was 36.31 ms, range 32.68–38.24 ms; head median 36.08 ms, range 31.77–52.78 ms. One of ten pairs exceeded +20%. Chronological paired changes were +8.09%, -3.02%, -5.73%, -13.61%, -3.40%, +38.02%, +8.09%, +15.17%, +7.65%, +5.60%.

In the original CI samples, much of the increase was inside the unchanged SQLFetchScroll_call timer. Both revisions made exactly 78 fetch calls and 77 row-construction/metadata batches, also confirmed in every local profiled ASCII-medium sample. This excludes additional fetch calls for that workload; it does not prove a root cause or rule out other effects.

Limits: Ubuntu matches CI's client Python/compiler versions, but runs under local Docker/WSL2 rather than the CI host. Local SQL2022 was 16.0.4225.2, versus 16.0.4325.4 in the affected CI run. These experiments do not qualify Windows/macOS/ARM64 performance, Arrow throughput, or bulk-copy throughput. The original CI regression remains unresolved pending reproducible source-level evidence or a comparable affected-environment run; the PR remains draft.

Commands below ran from the Python worktree, with $P pointing to the retained local performance-artifact directory. Harness scripts are local artifacts, not repository files:

Command Result
.\.venv\Scripts\python.exe "$P\run_comparison.py" --image mssql-python-perf-928:base-head --label base-head-run1 Passed: all six workloads and correctness assertions, five measured pairs per profiling/release mode
.\.venv\Scripts\python.exe "$P\summarize.py" "$P\base-head-run1" Passed: raw paired observations, medians and ranges retained
.\.venv\Scripts\python.exe "$P\run_comparison.py" --image mssql-python-perf-928:ubuntu-base-head --label ubuntu-base-head-run1 --rounds 11 Passed: all six workloads and correctness assertions, ten measured pairs per profiling/release mode
.\.venv\Scripts\python.exe "$P\summarize.py" "$P\ubuntu-base-head-run1" Passed: raw paired observations, medians and ranges retained

Raw outputs, provenance, build logs, scripts and performance-report.md are retained locally under perf-928; nothing was filtered to remove outliers. All task-owned SQL/client/build containers were removed with ownership and absence checks. Local images/evidence were retained, not published. No code change or new commit resulted from this investigation.

Real native-JSON source-build qualification

Tested Python production code at af29814308203e14f1effc46f3eb2b0ae8e773a2 with source-built Rust runtime d24a843c11861664395816efa58a129b3f783707. The test-only correction used in the passing runs is now committed as f1964e3d70662a18ab5d8f170523fc460f0c590f; its file hash was verified identical to the tested overlay before and after commit. Publication did not change production code, and no new live run is claimed after the byte-identical commit.

Both platforms rebuilt the C++ extension and used PyArrow 21.0.0, SQL Server 2025 17.0.5005.3, and an isolated development-only JSON-capable ODBC preview. The bootstrap verified actual query metadata SQL_JSON=-157, provider/native-library hashes, and the installed Rust wheel's SHA256. These runs used actual JSON server storage, not metadata interposition. MSSQL_TEST_NATIVE_JSON=1 was enabled after the capability probe. The private bulk qualification gate was enabled only inside the source-runtime test process; the production gate remains False.

Client / environment Source-runtime JSON integration Actual published Rust 0.5.0 compatibility
Windows x64, Python 3.13.17 123 passed, 0 skipped, 340 deselected 6 passed, 0 skipped, 287 deselected
Debian 12 x86_64 on Docker/WSL2, Python 3.13.15 123 passed, 0 skipped, 340 deselected 6 passed, 0 skipped, 287 deselected; isolated OpenSSL 1.1 libraries required
macOS Not run Not run

The same 123 case identities ran on Windows and Linux. Coverage includes native Json row bulk input, plain/canonical Arrow input, actual JSON Arrow output as large_string, SQL NULL, Unicode/large payloads, malformed/scalar document rejection, mapped/unmapped cells, producer failures, later-reader schema errors, and persistence of already committed batches. The six old-runtime cases cover typed rejection without tail consumption, diagnostic translation, unrelated-error preservation, and legacy dict/list/string/NULL JSON round trips. These counts include repository tests plus local qualification-only payload/baseline probes; they are not a full repository-suite count and do not qualify TVP or async JSON APIs.

Commands and results: the following were run from the retained local qualification-artifact directory. The lifecycle harness, manifests, bootstrap/probes, logs, JUnit and provenance are local test artifacts, not files committed by this PR. The harness injects credentials through the environment and supplies an isolated provider/runtime to the tests.

Command Result
python .\qualify_json_source_builds.py .\json-windows-qualified.json --output .\json-windows-qualified Passed: source runtime 123/123; published 0.5.0 baseline 6/6; owned SQL container cleanup verified
python .\qualify_json_source_builds.py .\json-linux-qualified.json --output .\json-linux-qualified Passed: source runtime 123/123; owned SQL/client container cleanup verified
python .\qualify_json_source_builds.py .\json-linux-baseline-qualified.json --output .\json-linux-baseline-qualified Passed: published 0.5.0 baseline 6/6 with isolated compatibility libraries; owned SQL/client container cleanup verified

The source-runtime bootstrap calls pytest on tests/test_json.py, tests/test_024_bulkcopy_arrow.py and the local qualify_json_payloads.py, selecting bulk_json or json_bulk or bulk_arrow_json or bulk_source_failure or json_arrow_returns or large_unicode_json_bulk or typed_json_invalid_document, with -q --no-cov --tb=short -rs and JUnit output.

Exact-source Rust importer/carrier/source-failure regressions also passed on Windows: 89 passed, 446 excluded. With $F pointing to the retained qualification-artifact root and the qualified Python environment selected, the command was:

cargo nextest run --manifest-path "$F\rust-source\microsoft-mssql-rs-d24a843\mssql-py-core\Cargo.toml" --locked --lib -E 'test(/^bulkcopy::tests::/) | test(/^arrow_bulkcopy::tests::/) | test(/^cursor::tests::/) | test(/^connection::tests::/)'

Source-built Rust wheel SHA256 values:

  • Windows: 2777e457fb7d33186ffae48af150ef23d0557255c1e81f9b59a6a1d2a2153e5f
  • Linux: dd9cef10ddaf55651eff695e0d07cc0bf4208ae7767885ce7d45cf4f4ec8c40d

The local runtime identifies as 0.6.0; this is not a published release. No preview binaries, wheels, credentials or test bootstrap were committed or published.

Failures encountered and resolved: the initial Windows exact-head run was 114 passed / 1 failed / 8 skipped. The failure was a test mock globally blocking json.dumps, including legitimate legacy-dictionary conversion; the narrow correction now in this PR preserves the no-reserialization assertion for typed snapshots. Eight cases initially skipped because the explicit native-JSON test flag was absent, then ran after the real capability probe. The initial Linux 0.5.0 baseline had 3 passes / 3 import failures because that published wheel requires libssl.so.1.1; genuine OpenSSL 1.1 libraries were added only to the isolated baseline container, with no host install or ABI substitution. The corrected baseline passed 6/6. Original failures and final results were retained separately.

All temporary SQL/client containers were removed and their absence verified. No system ODBC installation or production dependency/gate was changed.

Earlier SQL Server 2019 evidence and formatting/typing checks

The earlier Windows x64/Python 3.13.17/PyArrow 21.0.0 checks below are retained for transparency. Native JSON storage cases skipped on SQL Server 2019; the 14-case native Arrow selection used metadata interposition over real SQLGetData. Those earlier results alone were not native-storage qualification; the SQL Server 2025 results above supply that evidence.

Command (from Python worktree root) Result
.\.venv\Scripts\python.exe -m pytest tests\test_json.py tests\test_020_bulkcopy_auth_cleanup.py tests\test_024_bulkcopy_arrow.py -k 'not TestBulkcopyArrowLive' -q --no-cov 129 passed, 304 skipped, 31 deselected
.\.venv\Scripts\python.exe -m pytest -p qualified_json_runtime tests\test_json.py tests\test_024_bulkcopy_arrow.py -k 'bulk_source_failure or bulk_arrow_json or bulk_json_native' -q --no-cov 31 passed, 59 skipped, 358 deselected
.\.venv\Scripts\python.exe -m pytest tests\test_004_cursor_arrow.py -k 'native_json_arrow_streams or test_arrow_lob_wide or test_arrow_nolob_wide or test_arrow_single_column or test_arrow_empty_fetch or test_arrow_long_string' -q --no-cov 14 passed, 124 deselected
.\.venv\Scripts\python.exe -m pytest tests\test_typing.py -m typing -q --no-cov 9 passed with pinned mypy 2.3.1
.\.venv\Scripts\python.exe -m pre_commit validate-config Passed
.\.venv\Scripts\python.exe -m pre_commit run black-check --all-files --hook-stage pre-push Passed; rerun before committing/pushing the correction
git diff --check Passed; rerun before committing/pushing the correction

The earlier qualified_json_runtime plugin is also a local, non-repository test-process gate with exact wheel hash verification, not a production bypass. Commit/push hooks passed for f1964e3d; the PR remains draft.

Add native JSON Arrow text fetching and lazy mapped Json snapshots. Keep bulk enablement disabled pending a qualified published Rust runtime, and cover native fetch, source failure, and transaction contracts.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 1, 2026 05:53
@github-actions github-actions Bot added the pr-size: large Substantial code update label Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

PR Performance Report

⚠️ Performance regression detected

1 database task consistently slowed down across 1 measured environment.

0 IMPROVEMENTS 1 SLOWDOWN 2/2 ENVIRONMENTS

2 INCONSISTENT SLOWDOWNS

Signal fingerprint

Database task Unix / SQL Server 2022
5,000 x 8 VARCHAR(8000) / ASCII to UTF-16 35.3% slower
5,000 x 8 VARCHAR(8000) / UTF-8 to UTF-16 (astral) 21.4% inconsistent
200 x 8 VARCHAR(8000) / full-width CP1252 22.2% inconsistent

The largest recorded phase increases for these tasks are shown below. Phase timings are supporting evidence, not root-cause proof.
2 additional inconsistent slowdowns also need review.

Coverage: 2 of 2 environments completed. Advisory result; does not block merging.

Measured timings
Environment Database task Before After Change
Unix / SQL Server 2022 5,000 x 8 VARCHAR(8000) / ASCII to UTF-16 37.383 ms 59.186 ms +35.3%
Unix / SQL Server 2022 5,000 x 8 VARCHAR(8000) / UTF-8 to UTF-16 (astral) 90.812 ms 111.186 ms +21.4%
Unix / SQL Server 2022 200 x 8 VARCHAR(8000) / full-width CP1252 41.833 ms 43.293 ms +22.2%
Performance diagnostics

Phase times are inclusive diagnostics and must not be added together. They identify where measured time changed, not why it changed.

Unix / SQL Server 2022

5,000 x 8 VARCHAR(8000) / ASCII to UTF-16: ddbc::FetchBatchData +21.396 ms; py::fetchall::cpp_call +21.273 ms; ddbc::FetchAll_wrap +20.372 ms.
5,000 x 8 VARCHAR(8000) / UTF-8 to UTF-16 (astral): ddbc::FetchBatchData +20.436 ms; ddbc::FetchAll_wrap +20.429 ms; py::fetchall::cpp_call +20.395 ms.
200 x 8 VARCHAR(8000) / full-width CP1252: ddbc::FetchBatchData +1.459 ms; py::fetchall::cpp_call +1.448 ms; ddbc::FetchAll_wrap +1.447 ms.

All database tasks and timings

Unix / SQL Server 2022

Database task Before After Paired change Result
Connection opening 10.490 ms 10.110 ms -1.7% no signal
SELECT queries 1.314 ms 1.300 ms -2.6% no signal
Row insertion 32.480 ms 32.888 ms +0.4% no signal
Executemany inserts 162.198 ms 161.751 ms -1.6% no signal
Fetch-all queries 121.500 ms 121.053 ms -0.6% no signal
Row-by-row fetching 6.129 ms 6.147 ms +0.3% no signal
Batched row fetching 117.654 ms 120.993 ms +2.3% no signal
Transaction commit and rollback 109.480 ms 110.193 ms +0.3% no signal
Arrow row fetching 101.061 ms 100.555 ms -1.8% no signal
100,000-row insertion 362.453 ms 364.017 ms +1.0% no signal
Row fetching in batches of 100 126.195 ms 125.587 ms -0.5% no signal
Row fetching in batches of 10,000 125.008 ms 125.995 ms +2.0% no signal
Repeated positional queries 34.432 ms 33.947 ms -1.3% no signal
Repeated named-parameter queries 34.282 ms 34.399 ms -1.4% no signal
Legacy 100,000-row insertion 274.995 ms 272.436 ms -0.7% no signal
Insertion with explicit input sizes 546.614 ms 546.466 ms +0.2% no signal
Joined aggregation queries 183.968 ms 184.165 ms +0.2% no signal
Large joined-result fetching 190.481 ms 192.314 ms +1.7% no signal
1.2-million-row fetching 3582.442 ms 3551.009 ms -1.4% no signal
Common table expression queries 5.550 ms 5.674 ms +2.2% no signal
256 KiB VARCHAR(MAX) / fetchall() 0.953 ms 1.291 ms +29.6% no signal
10,000 scalar values / fetchval() (debug disabled) 20.320 ms 20.079 ms -0.2% no signal
10,000 output-converted rows / fetchall() 20.356 ms 19.783 ms -3.9% no signal
10,000 output-converted rows / fetchmany(1000) 24.451 ms 23.832 ms -2.5% no signal
10,000 INT/NVARCHAR rows / fetchmany(1) 28.679 ms 28.152 ms -1.4% no signal
5,000 x 8 VARCHAR(8000) / ASCII to UTF-16 37.383 ms 59.186 ms +35.3% consistent slowdown
5,000 x 8 VARCHAR(8000) / CP1252 to UTF-16 50.190 ms 57.664 ms +15.4% no signal
5,000 x 8 VARCHAR(8000) / UTF-8 to UTF-16 (astral) 90.812 ms 111.186 ms +21.4% inconsistent slowdown
5,000 x 8 NVARCHAR(4000) / UTF-16 (astral) 86.137 ms 92.011 ms +4.7% no signal
5,000 x 8 VARCHAR(8000) / short ASCII 10.754 ms 10.104 ms +0.4% no signal
200 x 8 VARCHAR(8000) / full-width ASCII 37.269 ms 44.193 ms +19.8% no signal
5,000 x 8 VARCHAR(8000) / short CP1252 12.545 ms 12.914 ms +2.0% no signal
200 x 8 VARCHAR(8000) / full-width CP1252 41.833 ms 43.293 ms +22.2% inconsistent slowdown
5,000 x 8 VARCHAR(8000) / short UTF-8 (astral) 15.918 ms 15.644 ms -0.6% no signal
200 x 8 VARCHAR(8000) / full-width UTF-8 (astral) 41.994 ms 48.764 ms +17.2% no signal
5,000 x 8 NVARCHAR(4000) / short UTF-16 (astral) 13.791 ms 13.951 ms +1.2% no signal
200 x 8 NVARCHAR(4000) / full-width UTF-16 (astral) 60.662 ms 62.760 ms +4.3% no signal
200,000 x 8 VARCHAR(32) / fetchall control 512.707 ms 543.464 ms +6.0% no signal
200,000 x 8 INT / fetchall control 274.473 ms 297.918 ms +4.6% no signal
10,000 rows x 32 columns / dict(row._mapping) (warm) 31.444 ms 31.416 ms +1.3% no signal

Unix / SQL Server 2025

Database task Before After Paired change Result
Connection opening 81.127 ms 81.110 ms -0.2% no signal
SELECT queries 1.346 ms 1.427 ms -1.0% no signal
Row insertion 32.085 ms 32.692 ms +3.9% no signal
Executemany inserts 153.147 ms 153.859 ms +0.5% no signal
Fetch-all queries 121.873 ms 122.519 ms +0.4% no signal
Row-by-row fetching 6.156 ms 6.247 ms +0.0% no signal
Batched row fetching 118.258 ms 118.285 ms -0.2% no signal
Transaction commit and rollback 109.807 ms 109.127 ms +0.0% no signal
Arrow row fetching 100.203 ms 100.518 ms +0.2% no signal
100,000-row insertion 381.768 ms 380.528 ms -0.3% no signal
Row fetching in batches of 100 127.995 ms 128.186 ms +0.9% no signal
Row fetching in batches of 10,000 127.622 ms 134.033 ms +2.3% no signal
Repeated positional queries 33.668 ms 33.344 ms -1.6% no signal
Repeated named-parameter queries 34.025 ms 33.790 ms -1.0% no signal
Legacy 100,000-row insertion 272.343 ms 274.118 ms +0.9% no signal
Insertion with explicit input sizes 551.411 ms 556.281 ms +0.9% no signal
Joined aggregation queries 164.579 ms 163.236 ms -0.6% no signal
Large joined-result fetching 188.441 ms 189.039 ms +1.3% no signal
1.2-million-row fetching 3552.873 ms 3531.188 ms -0.6% no signal
Common table expression queries 5.510 ms 5.365 ms +0.3% no signal
256 KiB VARCHAR(MAX) / fetchall() 1.499 ms 1.706 ms -21.8% no signal
10,000 scalar values / fetchval() (debug disabled) 19.999 ms 19.456 ms -1.1% no signal
10,000 output-converted rows / fetchall() 19.771 ms 20.315 ms +1.5% no signal
10,000 output-converted rows / fetchmany(1000) 24.112 ms 23.672 ms -2.7% no signal
10,000 INT/NVARCHAR rows / fetchmany(1) 28.256 ms 28.359 ms -0.1% no signal
5,000 x 8 VARCHAR(8000) / ASCII to UTF-16 50.444 ms 50.746 ms +1.6% no signal
5,000 x 8 VARCHAR(8000) / CP1252 to UTF-16 62.439 ms 62.102 ms +0.7% no signal
5,000 x 8 VARCHAR(8000) / UTF-8 to UTF-16 (astral) 115.354 ms 119.562 ms +9.5% no signal
5,000 x 8 NVARCHAR(4000) / UTF-16 (astral) 123.442 ms 127.473 ms +2.9% no signal
5,000 x 8 VARCHAR(8000) / short ASCII 10.034 ms 10.126 ms +0.8% no signal
200 x 8 VARCHAR(8000) / full-width ASCII 50.641 ms 50.547 ms -0.2% no signal
5,000 x 8 VARCHAR(8000) / short CP1252 13.031 ms 12.871 ms +0.8% no signal
200 x 8 VARCHAR(8000) / full-width CP1252 50.229 ms 50.025 ms -0.4% no signal
5,000 x 8 VARCHAR(8000) / short UTF-8 (astral) 16.198 ms 16.923 ms +3.8% no signal
200 x 8 VARCHAR(8000) / full-width UTF-8 (astral) 52.916 ms 53.482 ms +2.7% no signal
5,000 x 8 NVARCHAR(4000) / short UTF-16 (astral) 14.479 ms 14.319 ms -2.2% no signal
200 x 8 NVARCHAR(4000) / full-width UTF-16 (astral) 76.472 ms 84.332 ms +3.8% no signal
200,000 x 8 VARCHAR(32) / fetchall control 527.110 ms 503.516 ms -2.6% no signal
200,000 x 8 INT / fetchall control 272.027 ms 268.659 ms -1.6% no signal
10,000 rows x 32 columns / dict(row._mapping) (warm) 31.198 ms 30.997 ms -0.7% no signal
Build and measurement details

ADO build 196138

PR head: f1964e3d70662a18ab5d8f170523fc460f0c590f
Base: df875895484e9219753bb5bdce9f62cfb462692b
Measured merge: f8ebe38c24abf345589e14853f768706fc544002

  • Unix / SQL Server 2022: Python 3.12.3, x86_64, SQL 16.0.4325.4; 5 paired comparisons and 1 warmup.
  • Unix / SQL Server 2025: Python 3.12.3, x86_64, SQL 17.0.5065.9; 5 paired comparisons and 1 warmup.

A consistent change requires more than 20% median paired movement, at least 1 ms between the median runtimes, and at least 80% of pairs exceeding the relative threshold in the same direction. A slowdown without enough pair agreement is reported as inconsistent.

The displayed change is the median of paired before-and-after ratios. It is not recalculated from the two displayed median runtimes.

Both revisions use profiling-enabled builds on the same agent and database, with alternating order and discarded warmups. Results are diagnostic and do not represent production-wheel latency.

Raw samples and logs are attached to the ADO run as profiler-* artifacts.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The JSON adaptation helper converts list rows into tuples, bypassing the tuple/Row-only contract for mixed sources containing Json values.

1 open issue
What changed in this PR

Adds native JSON Arrow fetching to the synchronous driver and prepares typed JSON bulk input behind a release gate. This advances related work in #261 without claiming to resolve it; bulk input remains disabled on the current Rust runtime pin.

Changes:

  • Fetch native JSON as Arrow large_string() text through the UTF-16 streaming path.
  • Add lazy, mapped Json adaptation and document runtime requirements and transaction boundaries.
  • Require PyArrow 21+ and expand fetching, bulk-input, and producer-failure coverage.
File Description
tests/​test_json.py Tests JSON Arrow output and gated bulk adaptation.
tests/​test_024_bulkcopy_arrow.py Adds JSON producer, schema, and failure-boundary tests.
tests/​test_004_cursor_arrow.py Tests native JSON streaming with small reported column sizes.
tests/​conftest.py Adds qualified-runtime and JSON-server fixtures.
setup.py Raises the PyArrow extra minimum to 21.0.0.
README.md Documents JSON fetching, bulk release gates, and transaction limits.
mssql_python/​pybind/​ddbc_bindings.cpp Routes JSON Arrow values through wide-character streaming.
mssql_python/​json.py Adds lazy adaptation of mapped Json snapshots.
mssql_python/​cursor.py Enables JSON Arrow fetching and gates typed bulk adaptation.
mssql_python/​_pycore_types.pyi Declares the internal JSON carrier interface.

Review effort: Balanced

Comment thread mssql_python/json.py Resolved
Pass non-tuple rows through unchanged for native rejection. Add mixed tuple/list regressions for typed JSON and ordinary strings, covering row identity, lazy failure, and active-batch rollback.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 1, 2026 07:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Native JSON Arrow support requires human qualification with a real JSON-capable provider/server and across shipped platforms, because reported tests substituted NVARCHAR metadata rather than exercising actual JSON storage.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Allow json.dumps only for the reused legacy dictionary and assert exactly one serialization per row, while still rejecting snapshot reserialization and parsing.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 1, 2026 08:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Native JSON round trips remain unverified because validation used simulated metadata and an unpublished Rust wheel, leaving real-server, published-runtime, and cross-platform qualification for human review.

No open issues 🎉

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-size: large Substantial code update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants