Skip to content

Postgres: Support SUBSTRING SIMILAR/ESCAPE syntax and reversed FOR/FROM order - #2494

Open
BenSatori wants to merge 7 commits into
apache:mainfrom
BenSatori:postgres-substring-similar-escape
Open

BenSatori wants to merge 7 commits into
apache:mainfrom
BenSatori:postgres-substring-similar-escape

Conversation

@BenSatori

Copy link
Copy Markdown
Contributor

Fixes parsing of two legal Postgres SUBSTRING forms:

  • SUBSTRING('hello world' FOR 5 FROM 1) (FOR before FROM)
  • SUBSTRING('hello world' SIMILAR '%#"o w#"%' ESCAPE '#')

See https://www.postgresql.org/docs/current/functions-string.html

Both previously failed with a parser error. Adds a similar flag to Expr::Substring to track the SIMILAR ... ESCAPE display form, and allows FOR to be parsed before FROM (normalized to FROM ... FOR on output).

Generated with AI assistance (GitHub Copilot).

@codecov-commenter

codecov-commenter commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.00000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.09%. Comparing base (5cad906) to head (ebab908).

Files with missing lines Patch % Lines
src/parser/mod.rs 72.00% 0 Missing and 7 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2494      +/-   ##
==========================================
- Coverage   81.09%   81.09%   -0.01%     
==========================================
  Files          42       42              
  Lines       33684    33719      +35     
  Branches    33684    33719      +35     
==========================================
+ Hits        27316    27344      +28     
  Misses       2798     2798              
- Partials     3570     3577       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

Comment thread src/parser/mod.rs Outdated
Comment thread src/parser/mod.rs
Comment thread tests/sqlparser_common.rs
@LucaCappelletti94 LucaCappelletti94 added the waiting on contributor The review needs further refinements by its author label Sep 24, 2026
@LucaCappelletti94 LucaCappelletti94 added waiting on reviewer PR needs to be reviewed and removed waiting on contributor The review needs further refinements by its author labels Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PostgreSQL waiting on reviewer PR needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants