Skip to content

Conversation

@07ARB
Copy link
Contributor

@07ARB 07ARB commented Nov 12, 2019

What changes were proposed in this pull request?

lpad returning NULL instead of empty for empty pad value.

Why are the changes needed?

Need to add check-point if padding string is empty and require length is greater then zero.

Does this PR introduce any user-facing change?

NO

How was this patch tested?

Old unit tests correct as per this jira.

if (len > 0 && pad.numBytes() == 0) {
// no padding at all, return the null
return null;
} else if (spaces <= 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's correct to fix it here since the issue is specific to lpad expression. Can you check lpad in other DBMSes? I think we shouldn't just blindly follow Hive

Copy link
Contributor Author

@07ARB 07ARB Nov 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HyukjinKwon, fine i will check this point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HyukjinKwon, I checked in other DBMSes , please check below DBMSES output for lpad and rpad :

  1. Mysql : rpad ('hi', 5, '') => NULL and lpad ('hi', 5, '') => NULL
  2. Hive : rpad ('hi', 5, '') => NULL and lpad ('hi', 5, '') => NULL
  3. Postgresql : rpad ('hi', 5, '') => hi and lpad ('hi', 5, '') => hi

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine not to fix for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HyukjinKwon, but later we need fix ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current implementation is at least reasonable. If we should do, we could add a configuration to control the behaviour but to me it doesn't look worthy.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But as per rpad/lpad definition 'In case of empty pad string, the return value is null.' If we are not going to handle in 3.0 we can move to handle this in next version

@07ARB 07ARB closed this Nov 12, 2019
@07ARB 07ARB reopened this Nov 12, 2019
@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@07ARB 07ARB closed this Nov 12, 2019
@07ARB
Copy link
Contributor Author

07ARB commented Nov 12, 2019

@HyukjinKwon , please check and let me know whether we need to fix this issue ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants