Skip to content

perf(sqlite): preserve native options and bound Arrow loading - #820

Merged
cofin merged 12 commits into
mainfrom
feat/sqlite-adapters-optimization
Sep 28, 2026
Merged

cofin merged 12 commits into
mainfrom
feat/sqlite-adapters-optimization

Conversation

@cofin

@cofin cofin commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Preserve SQLite and aiosqlite native behavior while reducing adapter overhead. Keep cached query metadata, bounded Arrow conversion, cursor cleanup, and ADK batch writes. Retain custom window functions, configurable transaction modes, and Arrow import batch sizing with validation before transaction start.

Custom window functions require Python 3.11+ and a supporting SQLite runtime; configured functions fail clearly when the Python API is unavailable. Existing defaults remain unchanged: sqlite uses deferred transactions and aiosqlite uses BEGIN IMMEDIATE. Async window registration runs on the connection's worker thread.

Fix pooled in-memory connection recovery and roll back adapter-owned Arrow transactions on conversion failures or cancellation. Preserve caller-owned transactions, stdlib JSON behavior, quoted annotations, and per-statement async script cancellation boundaries. Tuple-stream additions were incomplete and remain excluded. Existing compiled helpers remain enabled; the expanded SQLite driver mypyc target is deferred pending exact compiled-wheel validation.

Validation: earlier focused driver/pool slice passed 86 tests with 2 Python-version skips; restoration regressions passed 4 tests. Affected adapters and tests pass Ruff; targeted adapter Pyright reports 0 errors/warnings. No services, full suite, or local compiled-wheel build were run.

Rebase validation: based on main a1067c856, with branch source changes preserved. Reconciled changelog entries, checked release-history preservation, and passed the focused documentation audit and whitespace checks. No runtime suites were rerun for this documentation-only update.

CI repair: register the consumed BigQuery storage_write_stream_type setting in the shared feature contract (exact regression passed). Docker pre-pulls retry up to three times with bounded backoff and preserve failure after exhaustion. YAML, shell syntax, scoped zizmor, and fake-command success/retry/failure checks passed. No local database services or broad test suites were run. Fresh hosted checks are pending on the updated head.

@codecov-commenter

codecov-commenter commented Sep 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.92181% with 83 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.17%. Comparing base (8148112) to head (ae5a930).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
sqlspec/adapters/aiosqlite/core.py 74.72% 18 Missing and 5 partials ⚠️
sqlspec/adapters/sqlite/adk/store.py 57.50% 16 Missing and 1 partial ⚠️
sqlspec/adapters/aiosqlite/adk/store.py 56.25% 13 Missing and 1 partial ⚠️
sqlspec/adapters/aiosqlite/pool.py 76.92% 10 Missing and 2 partials ⚠️
sqlspec/adapters/sqlite/core.py 83.92% 7 Missing and 2 partials ⚠️
sqlspec/adapters/aiosqlite/driver.py 91.48% 2 Missing and 2 partials ⚠️
sqlspec/adapters/sqlite/driver.py 96.15% 0 Missing and 2 partials ⚠️
sqlspec/adapters/sqlite/pool.py 96.96% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #820      +/-   ##
==========================================
- Coverage   81.60%   81.17%   -0.43%     
==========================================
  Files         521      521              
  Lines       78073    78208     +135     
  Branches    11235    11263      +28     
==========================================
- Hits        63714    63488     -226     
+ Misses      11130    11102      -28     
- Partials     3229     3618     +389     
Flag Coverage Δ
integration 62.42% <63.37%> (-0.06%) ⬇️
py3.10 79.38% <77.36%> (+0.10%) ⬆️
py3.11 71.08% <67.48%> (+11.21%) ⬆️
py3.12 79.38% <77.36%> (+0.09%) ⬆️
py3.13 79.39% <77.36%> (+0.10%) ⬆️
py3.14 80.52% <82.35%> (+18.97%) ⬆️
unit 71.66% <70.16%> (+0.61%) ⬆️

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

Files with missing lines Coverage Δ
sqlspec/adapters/aiosqlite/__init__.py 100.00% <ø> (ø)
sqlspec/adapters/aiosqlite/config.py 96.78% <100.00%> (+4.63%) ⬆️
sqlspec/adapters/aiosqlite/data_dictionary.py 74.21% <ø> (ø)
sqlspec/adapters/aiosqlite/events/store.py 100.00% <100.00%> (ø)
sqlspec/adapters/aiosqlite/litestar/store.py 91.30% <100.00%> (+0.15%) ⬆️
sqlspec/adapters/sqlite/__init__.py 100.00% <ø> (ø)
sqlspec/adapters/sqlite/config.py 95.20% <100.00%> (+3.54%) ⬆️
sqlspec/adapters/sqlite/data_dictionary.py 81.88% <ø> (ø)
sqlspec/adapters/sqlite/events/store.py 100.00% <100.00%> (ø)
sqlspec/adapters/sqlite/litestar/store.py 92.36% <100.00%> (ø)
... and 8 more

... and 65 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cofin cofin changed the title feat(adapters): optimize SQLite and AioSQLite adapters refactor(adapters): clean up SQLite and AioSQLite adapters Sep 25, 2026
@cofin
cofin force-pushed the feat/sqlite-adapters-optimization branch 6 times, most recently from 2f3d7c1 to 47fd8d2 Compare September 27, 2026 18:45
@cofin cofin changed the title refactor(adapters): clean up SQLite and AioSQLite adapters refactor(sqlite): optimize bounded loading and preserve lifecycle contracts Sep 27, 2026
@cofin cofin changed the title refactor(sqlite): optimize bounded loading and preserve lifecycle contracts perf(sqlite): preserve native options and bound Arrow loading Sep 27, 2026
@cofin
cofin force-pushed the feat/sqlite-adapters-optimization branch 3 times, most recently from be151e7 to 15672d3 Compare September 28, 2026 19:25
@cofin
cofin force-pushed the feat/sqlite-adapters-optimization branch from 15672d3 to ae5a930 Compare September 28, 2026 19:32
@cofin
cofin merged commit 06f5751 into main Sep 28, 2026
11 checks passed
@cofin
cofin deleted the feat/sqlite-adapters-optimization branch September 28, 2026 19:37
cofin added a commit that referenced this pull request Sep 29, 2026
## Summary

Prepares the v0.65.0 release:
- Bumps project version to `0.65.0` in `pyproject.toml` and updates
`uv.lock`.
- Updates `docs/changelog.rst` with the `v0.65.0` release notes covering
all 14 PRs merged since `v0.64.0`:
- IBM Db2 database adapter, SQLGlot dialect, and extension support
(#811, #823).
- Spanner and Spangres SQLGlot dialect isolation and AST support (#813).
  - Spanner adapter & store optimizations and release fixes (#814).
- MySQL family adapter consolidation and data-dictionary reorganization
(#821).
  - OracleDB adapter and store cleanup (#817, #823).
- Native controls and performance optimizations for BigQuery (#812),
PostgreSQL (#822), SQLite (#820), and MSSQL (#819).
  - Native Arrow capabilities and parse-once bindings (#818).
- Fixture JSON export/load, conflict keys normalization, and upsert
options (#824, #825, #826, #827).
- Quoted and schema-qualified migration `version_table` identifiers
(#815, #828, #829).
  - Builder CTE and column pruning ownership fixes (#829).

## Validation

- `make docs` passed without warnings or errors.
- `make lint` (ruff, prek, mypy, pyright, slotscheck, zizmor) passed
with 0 errors.
- Targeted unit tests passed.
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.

2 participants