Skip to content

feat(postgres): add pg_textsearch dialect and modular extension probing - #782

Merged
cofin merged 10 commits into
mainfrom
flow/postgres-extensions-bm25
Sep 13, 2026
Merged

cofin merged 10 commits into
mainfrom
flow/postgres-extensions-bm25

Conversation

@cofin

@cofin cofin commented Sep 13, 2026

Copy link
Copy Markdown
Member

Description

This PR introduces native support for AlloyDB and AlloyDB Omni's BM25 full-text search (pg_textsearch extension), decouples PostgreSQL extension dialects, and modularizes runtime extension probing:

  • Dialect & AST Parsing:
    • Adds PGTextSearch(Postgres) dialect registering custom <@> operator tokenization without colliding with PostgreSQL containment operators or requiring sqlglot upstream changes.
    • Decouples ParadeDB and PGVector dialects so both inherit independently from Postgres, resolving dialect hierarchy conflicts.
    • Registers entry point pg_textsearch in pyproject.toml and dialect mapping in sqlspec/core/splitter.py.
  • Active Extension State:
    • Replaces rigid dialect-string promotion with active_extensions: set[str] tracking in driver_features.
    • Exports is_postgres_extension_active() and standardizes build_postgres_extension_probe_names().
  • Adapter Integration:
    • Adds enable_pg_textsearch: bool = True across all PostgreSQL adapters (asyncpg, psycopg, adbc, psqlpy).
    • Unifies first-connection probing across adapters, replacing ad-hoc ADK memory probes.
  • Documentation & Compilation:
    • Registers _pg_textsearch.py in mypyc exclusions and inventory boundary maps.
    • Updates Sphinx reference docs (docs/reference/dialects.rst, adapter docs) and changelog (docs/changelog.rst).

Verification

  • make lint (passed: Prek, Ruff, Codespell, slotscheck, Actions audit)
  • make type-check (passed: Mypy, Pyright 0 errors)
  • make docs (passed: build succeeded)
  • Unit tests: 2,645 passed across dialects, core, and all PostgreSQL adapters

@cofin
cofin force-pushed the flow/postgres-extensions-bm25 branch from 28e590c to 923e882 Compare September 13, 2026 18:29
@codecov-commenter

codecov-commenter commented Sep 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.51724% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.15%. Comparing base (8547d5d) to head (5192045).

Files with missing lines Patch % Lines
sqlspec/core/config_runtime.py 76.19% 2 Missing and 3 partials ⚠️
sqlspec/adapters/adbc/type_converter.py 0.00% 0 Missing and 2 partials ⚠️
sqlspec/adapters/psycopg/config.py 81.81% 2 Missing ⚠️
sqlspec/adapters/adbc/core.py 92.85% 0 Missing and 1 partial ⚠️
sqlspec/dialects/postgres/_generators.py 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #782      +/-   ##
==========================================
+ Coverage   76.96%   78.15%   +1.19%     
==========================================
  Files         487      488       +1     
  Lines       71929    72003      +74     
  Branches    10075    10084       +9     
==========================================
+ Hits        55361    56277     +916     
+ Misses      13149    12271     -878     
- Partials     3419     3455      +36     
Flag Coverage Δ
integration 61.07% <67.24%> (+2.20%) ⬆️
py3.10 76.47% <89.65%> (+0.02%) ⬆️
py3.11 66.64% <89.65%> (+0.05%) ⬆️
py3.12 76.47% <89.65%> (+0.02%) ⬆️
py3.13 76.48% <89.65%> (+9.89%) ⬆️
py3.14 77.40% <89.28%> (+11.27%) ⬆️
unit 66.98% <89.65%> (+0.05%) ⬆️

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

Files with missing lines Coverage Δ
sqlspec/adapters/adbc/config.py 93.22% <100.00%> (+0.44%) ⬆️
sqlspec/adapters/asyncpg/config.py 93.56% <100.00%> (+0.35%) ⬆️
sqlspec/adapters/asyncpg/core.py 79.09% <100.00%> (+0.08%) ⬆️
sqlspec/adapters/psqlpy/config.py 92.69% <100.00%> (+0.25%) ⬆️
sqlspec/adapters/psqlpy/core.py 76.60% <100.00%> (+0.04%) ⬆️
sqlspec/adapters/psycopg/core.py 92.80% <100.00%> (+0.02%) ⬆️
sqlspec/builder/_ddl.py 68.61% <100.00%> (+0.14%) ⬆️
sqlspec/core/splitter.py 80.47% <ø> (ø)
sqlspec/dialects/__init__.py 70.00% <100.00%> (+30.00%) ⬆️
sqlspec/dialects/postgres/__init__.py 100.00% <100.00%> (ø)
... and 9 more

... and 40 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 merged commit 9c45b10 into main Sep 13, 2026
27 checks passed
@cofin
cofin deleted the flow/postgres-extensions-bm25 branch September 13, 2026 20:07
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