[ 
https://issues.apache.org/jira/browse/SPARK-48284?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18051451#comment-18051451
 ] 

Yang Jie commented on SPARK-48284:
----------------------------------

What is the basis for determining the correct behavior described? I executed 
the provided example in Java 17 jshell, and it seems that the returned value is 
different from what's described.

 
{code:java}
jshell> "abc".indexOf("", 0);
$1 ==> 0


jshell> "abc".indexOf("", 2);
$2 ==> 2


jshell> "abc".indexOf("", 9);
$3 ==> 3


jshell> "abc".indexOf("", -3);
$4 ==> 0 {code}

> Fix UTF8String indexOf behaviour for empty string search
> --------------------------------------------------------
>
>                 Key: SPARK-48284
>                 URL: https://issues.apache.org/jira/browse/SPARK-48284
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 4.0.0
>            Reporter: Uroš Bojanić
>            Priority: Major
>              Labels: pull-request-available
>
> Currently, UTF8String.indexOf returns 0 when given an empty parameters 
> string, and any integer start value.
> Examples:
> {{"abc".indexOf("", 0);  // returns: 0}}
> {{"abc".indexOf("", 2);  // returns: 0}}
> {{"abc".indexOf("", 9);  // returns: 0}}
> {{"abc".indexOf("", -3); // returns: 0}}
> This is not correct, as "start" is not taken into consideration.
> Correct behaviour would be:
> {{"abc".indexOf("", 0);  // returns: 0}}
> {{"abc".indexOf("", 2);  // returns: 2}}
> {{"abc".indexOf("", 9);  // returns: -1}}
> {{"abc".indexOf("", -3); // returns: -1}}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to