You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "sarutak (via GitHub)" <gi...@apache.org> on 2026/07/13 04:08:38 UTC
[PR] [SPARK-57932][SQL][4.2] Fix regexp_instr and regexp_replace returning wrong results for supplementary characters [spark]
sarutak opened a new pull request, #57213:
URL: https://github.com/apache/spark/pull/57213
### What changes were proposed in this pull request?
This PR backports SPARK-57932 (#56998) for `branch-4.2` with conflict resolution.
`regexp_instr` returned matcher.start() + 1 (a UTF-16 code-unit index), and `regexp_replace`'s position argument was used as a UTF-16 offset in matcher.region(pos-1, ...) and its out-of-range guard. Both now use code-point positions via codePointCount/offsetByCodePoints.
### Why are the changes needed?
Spark string positions are 1-based code points (instr, locate, position, substring, length). For strings containing supplementary characters (code points > U+FFFF, e.g. emojis), these two functions gave wrong results:
- regexp_instr('😀ab', 'ab') returned 3 instead of 2.
- regexp_replace('😀aXa', 'a', 'Z', 3) returned 😀ZXZ instead of 😀aXZ (replaced a match before position); regexp_replace('😀😀', '😀', 'Z', 3) returned 😀Z instead of the input unchanged. This is the sibling of the LIKE fix in SPARK-55453.
### Does this PR introduce _any_ user-facing change?
Yes. regexp_instr and regexp_replace now return code-point-consistent results for strings with supplementary characters.
### How was this patch tested?
Added UT.
### 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-57932][SQL][4.2] Fix regexp_instr and regexp_replace returning wrong results for supplementary characters [spark]
Posted by "sarutak (via GitHub)" <gi...@apache.org>.
sarutak closed pull request #57213: [SPARK-57932][SQL][4.2] Fix regexp_instr and regexp_replace returning wrong results for supplementary characters
URL: https://github.com/apache/spark/pull/57213
--
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-57932][SQL][4.2] Fix regexp_instr and regexp_replace returning wrong results for supplementary characters [spark]
Posted by "sarutak (via GitHub)" <gi...@apache.org>.
sarutak commented on PR #57213:
URL: https://github.com/apache/spark/pull/57213#issuecomment-4963906124
**Merge Summary:**
- merged into branch-4.2 https://github.com/apache/spark/commit/666afb88e670db245889a3aaa474c08d4a0f52e1
*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