You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "jiwen624 (via GitHub)" <gi...@apache.org> on 2026/07/30 07:13:59 UTC
[PR] [SPARK-58443][SQL] Fix instr returning a wrong position for Int.MinValue start due to negation overflow in UTF8String.indexOf [spark]
jiwen624 opened a new pull request, #57648:
URL: https://github.com/apache/spark/pull/57648
### What changes were proposed in this pull request?
In `UTF8String.indexOf(pattern, start, occurrence)`, return not-found before negating `start` when it is `Int.MinValue`. `-Int.MinValue` overflows back to `Int.MinValue` (negative), so the backward-skip loop never ran and the out-of-range guard `charCount < charsToSkip` could not fire — the backward search then ran anchored at the end of the string. Such a start can never be in range, since string length is bounded by `Int.MaxValue`.
### Why are the changes needed?
`instr` with `start = Int.MinValue` silently returns the position of the last match instead of 0 (not found):
```sql
SELECT instr('abcabc', 'abc', -2147483648, 1); -- returns 4, expected 0
```
Every other out-of-range negative start correctly returns 0. Affects the UTF8_BINARY and UTF8_LCASE paths; ICU collations already return 0 for the same query, so this was also an internal inconsistency across collations.
### Does this PR introduce _any_ user-facing change?
Yes - bug fix
### How was this patch tested?
New test cases added
### Was this patch authored or co-authored using generative AI tooling?
Yes
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58443][SQL] Fix wrong results/exception in instr and substring_index for an Integer.MIN_VALUE position or count [spark]
Posted by "jiwen624 (via GitHub)" <gi...@apache.org>.
jiwen624 commented on PR #57648:
URL: https://github.com/apache/spark/pull/57648#issuecomment-5248682954
Hi @uros-b @dongjoon-hyun @HyukjinKwon Thank you very much for the review. 👍 Do you have other concerns on the change?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58443][SQL] Fix wrong results/exception in instr and substring_index for an Integer.MIN_VALUE position or count [spark]
Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b commented on PR #57648:
URL: https://github.com/apache/spark/pull/57648#issuecomment-5151380633
Thank you @jiwen624!
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58443][SQL] Fix wrong results/exception in instr and substring_index for an Integer.MIN_VALUE position or count [spark]
Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b closed pull request #57648: [SPARK-58443][SQL] Fix wrong results/exception in instr and substring_index for an Integer.MIN_VALUE position or count
URL: https://github.com/apache/spark/pull/57648
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58443][SQL] Fix wrong results/exception in instr and substring_index for an Integer.MIN_VALUE position or count [spark]
Posted by "jiwen624 (via GitHub)" <gi...@apache.org>.
jiwen624 commented on PR #57648:
URL: https://github.com/apache/spark/pull/57648#issuecomment-5448503167
Gentle ping @uros-b @dongjoon-hyun @HyukjinKwon Please let me know if this PR is good to go or anything still needs to be addressed. Thank you. 🙇
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58443][SQL] Fix wrong results/exception in instr and substring_index for an Integer.MIN_VALUE position or count [spark]
Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b commented on PR #57648:
URL: https://github.com/apache/spark/pull/57648#issuecomment-5508742303
**Merge Summary:**
- merged into master https://github.com/apache/spark/commit/a9e9132bac5093119362d6dbfd0d3b80af2eebfc
- merged into branch-4.x https://github.com/apache/spark/commit/439a757720becc961efa7453da5818a5b02ae404
- merged into branch-4.3 https://github.com/apache/spark/commit/294e41b2c1da59de42d313c6a25778393ebd4e75
*Posted by `merge_spark_pr.py`*
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org