uros-db commented on code in PR #48521:
URL: https://github.com/apache/spark/pull/48521#discussion_r1815179498
##########
common/unsafe/src/main/java/org/apache/spark/sql/catalyst/util/CollationAwareUTF8String.java:
##########
@@ -1357,8 +1514,16 @@ public static UTF8String trimRight(
else charIndex -= longestMatchLen;
}
- // Return the substring from the start of the string until that position.
- return UTF8String.fromString(src.substring(0, charIndex));
+ // Return the substring from the start of the string until that position
and append
+ // trailing spaces if they were ignored
+ int trailingLength = src.length() - lastNonSpacePosition;
+ StringBuilder sb =
+ new StringBuilder(charIndex + (Math.max(trailingLength, 0)));
+ sb.append(src, 0, charIndex);
+ if (lastNonSpacePosition != src.length()) {
+ sb.append(src, lastNonSpacePosition, src.length());
+ }
+ return UTF8String.fromString(sb.toString());
Review Comment:
let's use the concat approach
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]