Skip to content

[AURON #2132] Add native support for instr function#2133

Closed
weimingdiit wants to merge 1 commit intoapache:masterfrom
weimingdiit:feat/add-instr-function
Closed

[AURON #2132] Add native support for instr function#2133
weimingdiit wants to merge 1 commit intoapache:masterfrom
weimingdiit:feat/add-instr-function

Conversation

@weimingdiit
Copy link
Copy Markdown
Contributor

@weimingdiit weimingdiit commented Mar 29, 2026

Which issue does this PR close?

Closes ##2132

Rationale for this change

To improve compatibility with Spark SQL string functions, we should support instr(str, substr) with Spark-compatible semantics.

Expected behavior

Function name: instr(str, substr)

Return value:

  • Returns the 1-based index of the first occurrence of substr in str
  • Returns 0 if substr is not found
  • Returns 1 if substr is an empty string
  • Returns NULL if either argument is NULL

Examples:

  • instr('hello', 'll') -> 3
  • instr('hello', 'x') -> 0
  • instr('hello', '') -> 1

This behavior should match Spark SQL and work consistently for literal and expression inputs.

What changes are included in this PR?

This PR adds support for the Spark SQL instr() function in the native conversion path.
The following changes are included:

  • Added StringInstr expression support in NativeConverters
  • Mapped Spark instr(str, substr) to the existing native strpos scalar function
  • Added regression tests to verify correctness for:
    • successful substring match
    • substring not found
    • empty substring handling
    • null input handling

Are there any user-facing changes?

NO.

How was this patch tested?

CI.

@github-actions github-actions bot added the spark label Mar 29, 2026
@weimingdiit weimingdiit marked this pull request as ready for review March 29, 2026 01:20
@slfan1989 slfan1989 self-assigned this Mar 29, 2026
Signed-off-by: weimingdiit <weimingdiit@gmail.com>
@weimingdiit weimingdiit force-pushed the feat/add-instr-function branch from 9e6d976 to c3b61d0 Compare March 29, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants