Skip to content

feat(postgres): add configurable pg_trgm extension support#2251

Open
benfdking wants to merge 4 commits intomainfrom
feat/postgres-pgtrgm-config
Open

feat(postgres): add configurable pg_trgm extension support#2251
benfdking wants to merge 4 commits intomainfrom
feat/postgres-pgtrgm-config

Conversation

@benfdking
Copy link
Collaborator

Summary

  • Add support for PostgreSQL pg_trgm extension operators (%, <%, %>, <->, etc.)
  • Make pg_trgm support opt-in via dialect configuration
  • Add test infrastructure for per-folder dialect config in test fixtures

To enable pg_trgm operators, add to your .sqruff config:

[sqruff:dialect:postgres]
pg_trgm = true

See: https://www.postgresql.org/docs/current/pgtrgm.html

Fixes #1180

Based on work from #1186 by @lu-zero and @gvozdvmozgu

Test plan

  • bazel test //... passes
  • pg_trgm operators parse correctly when enabled
  • pg_trgm operators don't interfere when disabled

🤖 Generated with Claude Code

lu-zero and others added 4 commits January 31, 2026 22:05
The pg_trgm extension operators are now opt-in via dialect config.
To enable, add to your .sqruff config:

[sqruff:dialect:postgres]
pg_trgm = true

Also adds support for per-folder dialect config in test fixtures.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions
Copy link

Benchmark for 4f8f330

Click to view benchmark
Test Base PR %
DepthMap::from_parent 52.4±1.69µs 52.3±0.60µs -0.19%
fix_complex_query 12.3±0.07ms 12.3±0.06ms 0.00%
fix_superlong 156.5±3.06ms 174.5±4.71ms +11.50%
parse_complex_query 4.2±0.05µs 4.2±0.06µs 0.00%
parse_expression_recursion 7.1±0.07µs 7.5±0.12µs +5.63%
parse_simple_query 1035.1±19.29ns 1058.0±27.35ns +2.21%

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 1, 2026

Merging this PR will improve performance by 18.84%

⚡ 2 improved benchmarks
✅ 4 untouched benchmarks
⏩ 6 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime parse_complex_query 16.7 µs 14.9 µs +11.99%
WallTime parse_expression_recursion 27.7 µs 23.3 µs +18.84%

Comparing feat/postgres-pgtrgm-config (f2f29e7) with main (dcda784)2

Open in CodSpeed

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (ac70e23) during the generation of this report, so dcda784 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

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.

[Bug]: the postgres dialect does not preserve/understand pg_trgm operators

3 participants