[ 
https://issues.apache.org/jira/browse/SPARK-58443?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eric Yang updated SPARK-58443:
------------------------------
    Description: 
Wrong results for an Int.MinValue position or count:


{code:sql}
SELECT instr('abcabc', 'abc', -2147483648, 1);
-- returns 4, expected 0

SELECT substring_index('a.b.c', '.', -2147483648);
-- throws NegativeArraySizeException, expected a.b.c

SELECT substring_index(collate('a.b.c', 'UTF8_LCASE'), '.', -2147483648);
-- returns '', expected a.b.c
{code}


  was:
The 3/4-argument instr (SPARK-57436) returns the position of a match instead of 
0 (not found) when start is Int.MinValue, which is out of range for any string:

{code:sql}
-- returns 4, expected 0 (start is far before the beginning of the string)
SELECT instr('abcabc', 'abc', -2147483648, 1);
{code}


> Wrong results in instr and substring_index for an Int.MinValue position or 
> count
> --------------------------------------------------------------------------------
>
>                 Key: SPARK-58443
>                 URL: https://issues.apache.org/jira/browse/SPARK-58443
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 5.0.0
>            Reporter: Eric Yang
>            Priority: Major
>              Labels: pull-request-available
>
> Wrong results for an Int.MinValue position or count:
> {code:sql}
> SELECT instr('abcabc', 'abc', -2147483648, 1);
> -- returns 4, expected 0
> SELECT substring_index('a.b.c', '.', -2147483648);
> -- throws NegativeArraySizeException, expected a.b.c
> SELECT substring_index(collate('a.b.c', 'UTF8_LCASE'), '.', -2147483648);
> -- returns '', expected a.b.c
> {code}



--
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