Skip to content

Conversation

@10110346
Copy link
Contributor

@10110346 10110346 commented Jun 8, 2017

What changes were proposed in this pull request?

When converting string to number(int, long or double), if the string has a space before or after,will lead to unnecessary mistakes.

How was this patch tested?

unit test

@wzhfy
Copy link
Contributor

wzhfy commented Jun 10, 2017

If a string has a leading or trailing space, it's expected it cannot be converted to a number.
Java's string type also follows this convention.

@10110346
Copy link
Contributor Author

10110346 commented Jun 10, 2017

But it can be converted to double.
If a string has a leading or trailing space, we are not easy to detect, especially the user configuration,this Pr is to solve this problem.

@kiszk
Copy link
Member

kiszk commented Jun 10, 2017

It would be good to do the same thing for s.toBoolean in toBoolean method.

@HyukjinKwon
Copy link
Member

I think it will be more persuasive if there are some cases where users mistakenly write wrong values for both numbers and booleans. Personally, I haven't got any errors about this before (more than two years in production / development).

@10110346
Copy link
Contributor Author

@HyukjinKwon I agree with you ,but i think if add trim', it would be better

@gatorsmile
Copy link
Member

Although it is not a common user error, it does not hurt to add an extra trim.

@gatorsmile
Copy link
Member

ok to test

@SparkQA
Copy link

SparkQA commented Jun 12, 2017

Test build #77917 has started for PR 18238 at commit 04307c6.

@SparkQA
Copy link

SparkQA commented Jun 12, 2017

Test build #77921 has finished for PR 18238 at commit 9317956.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@srowen
Copy link
Member

srowen commented Jun 12, 2017

I'm neutral. Accepting bad input isn't usually a great idea, though in this case, I can't see much harm. It's not ambiguous.

@SparkQA
Copy link

SparkQA commented Jun 12, 2017

Test build #77930 has finished for PR 18238 at commit c09eaa1.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@gatorsmile
Copy link
Member

retest this please

@SparkQA
Copy link

SparkQA commented Jun 12, 2017

Test build #77944 has finished for PR 18238 at commit c09eaa1.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jun 13, 2017

Test build #77966 has started for PR 18238 at commit c09eaa1.

@10110346
Copy link
Contributor Author

Jenkins, retest this please

@SparkQA
Copy link

SparkQA commented Jun 13, 2017

Test build #77982 has finished for PR 18238 at commit c09eaa1.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@gatorsmile
Copy link
Member

Thanks! Merging to master.

@asfgit asfgit closed this in 7ba8bf2 Jun 13, 2017
dataknocker pushed a commit to dataknocker/spark that referenced this pull request Jun 16, 2017
…g to number

## What changes were proposed in this pull request?
When converting `string` to `number`(int, long or double),  if the string has a space before or after,will lead to unnecessary mistakes.

## How was this patch tested?
unit test

Author: liuxian <[email protected]>

Closes apache#18238 from 10110346/lx-wip-0608.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants