07ARB commented on a change in pull request #26478: [SPARK-29853][SQL]lpad
returning empty instead of NULL for empty pad …
URL: https://github.com/apache/spark/pull/26478#discussion_r345687541
##########
File path:
common/unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java
##########
@@ -882,7 +882,10 @@ public UTF8String rpad(int len, UTF8String pad) {
*/
public UTF8String lpad(int len, UTF8String pad) {
int spaces = len - this.numChars(); // number of char need to pad
- if (spaces <= 0 || pad.numBytes() == 0) {
+ if (len > 0 && pad.numBytes() == 0) {
+ // no padding at all, return the null
+ return null;
+ } else if (spaces <= 0) {
Review comment:
@HyukjinKwon, but later we need fix ?
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]