xuanyuanking commented on a change in pull request #28937:
URL: https://github.com/apache/spark/pull/28937#discussion_r446613486
##########
File path:
common/unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java
##########
@@ -341,8 +341,17 @@ public UTF8String substringSQL(int pos, int length) {
// to the -ith element before the end of the sequence. If a start index i
is 0, it
// refers to the first element.
int len = numChars();
+ // `len + pos` does not overflow as `len >= 0`.
Review comment:
The negative `pos` here `refers to the -ith element before the end of
the sequence`, so if pos = Integer.MIN_VALUE, then the start should be `pos +
len`. The final result of `EMPTY_UTF8` will be returned by `substring` when its
param start and until are both negative. I also added a UT in 4dcfe81.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]