Skip to content

test: Fix malformed regexp_instr error tests and add slt coverage#23620

Open
alamb wants to merge 1 commit into
apache:mainfrom
alamb:alamb/regexp_instr_slt_coverage
Open

test: Fix malformed regexp_instr error tests and add slt coverage#23620
alamb wants to merge 1 commit into
apache:mainfrom
alamb:alamb/regexp_instr_slt_coverage

Conversation

@alamb

@alamb alamb commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

N/A (found while reviewing test coverage for #23540)

Rationale for this change

While checking cargo llvm-cov coverage of regexp_instr, I found that the two statement error tests for start < 1 in regexp_instr.slt never actually exercise the start validation.

Coverage also showed two paths of regexp_instr untested anywhere:

  • the N must be 1 or greater error for nth < 1
  • looking up an already-compiled regex from the per-batch cache when the pattern column returns to a previously seen pattern (e.g. ['abc', 'def', 'abc']). This path becomes more important with the memoization added in perf: optimize regexp_instr (40% faster) #23540.

What changes are included in this PR?

  • Fix the two malformed statement error tests so the expected error is matched inline against the real message
  • Add a statement error test for nth < 1
  • Add a test with a pattern column that alternates between two regexes within a single batch

Are these changes tested?

Yes, this PR is only tests.

Are there any user-facing changes?

No

The two existing 'statement error' tests for start < 1 placed the expected
error message on the line after 'statement error', so the runner parsed the
message as part of the SQL. The resulting two-line statement failed to parse
and the bare 'statement error' accepted that parse error, meaning the start
validation was never actually exercised (the expected text also said
'1 based' while the actual error says '1-based').

Also add coverage for two previously untested paths:
- the 'N must be 1 or greater' error for nth < 1
- a pattern column that alternates between two regexes in one batch,
  exercising the compiled-regex cache lookup for a previously seen pattern

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions github-actions Bot added the sqllogictest SQL Logic Tests (.slt) label Jul 15, 2026
@alamb alamb marked this pull request as ready for review July 15, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant