[
https://issues.apache.org/jira/browse/SPARK-60125?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
ASF GitHub Bot updated SPARK-60125:
-----------------------------------
Labels: pull-request-available (was: )
> regexp_instr ignores the specified regex group index
> ----------------------------------------------------
>
> Key: SPARK-60125
> URL: https://issues.apache.org/jira/browse/SPARK-60125
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 5.0.0
> Environment: Spark: 5.0.0-SNAPSHOT
> Commit: 38422aefaf599ffb4cfa579d98898d95b1f02081
> Java: OpenJDK 17.0.17
> OS: macOS 15.7.4
> Reporter: Yibo Dong
> Priority: Major
> Labels: pull-request-available
>
> h2. What happened
> {{regexp_instr}} returns the start position of the full regex match even when
> a different capture group is selected using the third argument. This produces
> an incorrect result when the selected group starts after the full match.
> h2. How to reproduce
> Run the following SQL using {{spark-sql}}:
> {code:sql}
> SELECT regexp_instr('abc123', '([a-z]+)([0-9]+)', 2) AS position;
> {code}
> Save the SQL as {{repro.sql}} and run:
> {code:bash}
> spark-sql --master 'local[2]'
> --conf spark.ui.enabled=false
> -f repro.sql
> {code}
> h2. Expected result
> The second capture group matches {{123}}, which starts at the fourth
> character of {{abc123}}. The result should be:
> {code:text}
> position
> --------
> 4
> {code}
> h2. Actual result
> The query returns the start position of the full match:
> {code:text}
> position
> --------
> 1
> {code}
> h2. Additional information
> Spark's ocumentation defines the third argument, {{idx}}, as the matched
> regex group index.
> The implementation appears to use the start position of the full match
> without considering the selected group index.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]