You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geaflow.apache.org by "lkxdsb (via GitHub)" <gi...@apache.org> on 2026/07/29 06:13:16 UTC
[PR] Fix negative from index handling in INSTR [geaflow]
lkxdsb opened a new pull request, #820:
URL: https://github.com/apache/geaflow/pull/820
### What changes were proposed in this pull request?
- make `INSTR` interpret a negative `from` argument as a position counted from the end of the string and search backward from that position
- support the same behavior for both `String` and `BinaryString` overloads
- add unit coverage for multiple backward matches, overlapping matches, multibyte strings, and out-of-range positions
- add a local GeaFlow runtime integration test that executes `INSTR` through the SQL pipeline and verifies the file sink result
### Why are the changes needed?
The existing implementation converts `from` directly to a zero-based forward index. Negative values therefore enter the invalid-index branch instead of performing the documented backward search, which causes incorrect results.
With this change, negative positions use 1-based return values consistently, the `nth` occurrence is counted while searching backward, and no match returns `0`.
Fixes #87
### How was this PR tested?
- `JAVA_HOME=$(/usr/libexec/java_home -v 11) mvn -pl geaflow/geaflow-dsl/geaflow-dsl-plan -Dtest=UDFInstrTest test`
- `JAVA_HOME=$(/usr/libexec/java_home -v 11) mvn -pl geaflow/geaflow-dsl/geaflow-dsl-runtime -Dtest=InstrRuntimeTest test`
- `git diff --check`
The runtime integration test starts the local GeaFlow environment and validates the sink output as `4,1,3,2,0`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@geaflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@geaflow.apache.org
For additional commands, e-mail: issues-help@geaflow.apache.org