You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by 10110346 <gi...@git.apache.org> on 2017/05/31 06:39:04 UTC

[GitHub] spark pull request #18156: [SPARK-20933][SQL]when the input parameter is flo...

GitHub user 10110346 opened a pull request:

    https://github.com/apache/spark/pull/18156

    [SPARK-20933][SQL]when the input parameter is float type,the ’round ’ or  ‘bround’ function can't work well

    ## What changes were proposed in this pull request?
    spark-sql>select round(cast(3.1415 as float), 3);
    spark-sql>3.141
    For this case, the result we expected is 3.142
    
    spark-sql>select bround(cast(3.1415 as float), 3);
    spark-sql>3.141
    For this case, the result we expected is 3.142
    ## How was this patch tested?
    add unit test


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/10110346/spark wip-lx-0526

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/18156.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #18156
    
----
commit ea2a8ce9fa8f8f70847c08d732a0397e4ca473e2
Author: liuxian <li...@zte.com.cn>
Date:   2017-05-31T06:19:39Z

    when the input parameter is float type,the ’round ’ and  ‘bround’
    function can't work well

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #18156: [SPARK-20933][SQL]when the input parameter is float type...

Posted by 10110346 <gi...@git.apache.org>.
Github user 10110346 commented on the issue:

    https://github.com/apache/spark/pull/18156
  
    maybe i have understood,thanks @srowen 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #18156: [SPARK-20933][SQL]when the input parameter is float type...

Posted by 10110346 <gi...@git.apache.org>.
Github user 10110346 commented on the issue:

    https://github.com/apache/spark/pull/18156
  
    I don't understand why the value of 3.1415f  is  actually something like 3.14149999...
    From the user's point of view, i think 3.142 maybe more  reasonable.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #18156: [SPARK-20933][SQL]when the input parameter is flo...

Posted by 10110346 <gi...@git.apache.org>.
Github user 10110346 closed the pull request at:

    https://github.com/apache/spark/pull/18156


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #18156: [SPARK-20933][SQL]when the input parameter is float type...

Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on the issue:

    https://github.com/apache/spark/pull/18156
  
    No, that's not how floating-point works. Even 0.1 as a double isn't exactly 0.1.
    No, converting to double from float does not lose precision, but this is beside the point.
    3.1415 as a double is also not exactly 3.1415. I don't understand what you're trying to point out; of course the narrowing conversion from 3.1415d to float matches 3.1415f. This doesn't change the fact that the rounding answer is correct here. I think you are thinking of the case where you specified 3.1415 as a decimal type.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #18156: [SPARK-20933][SQL]when the input parameter is float type...

Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on the issue:

    https://github.com/apache/spark/pull/18156
  
    Although I agree that 3.1415 should round to 3.141 in both cases, the value of 3.1415f is not quite the same as 3.1415. It's actually something like 3.14149999...  The behavior is correct, therefore. You should find that rounding 3.1415 as a double or string gives the answer you're expecting.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #18156: [SPARK-20933][SQL]when the input parameter is float type...

Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on the issue:

    https://github.com/apache/spark/pull/18156
  
    Try evaluating 3.1415f < 3.1415. It is true. Floating point representation is inexact and in your example you explicitly choose the inexact representation


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #18156: [SPARK-20933][SQL]when the input parameter is float type...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/18156
  
    Can one of the admins verify this patch?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #18156: [SPARK-20933][SQL]when the input parameter is float type...

Posted by 10110346 <gi...@git.apache.org>.
Github user 10110346 commented on the issue:

    https://github.com/apache/spark/pull/18156
  
    Yes,Floating point representation is inexact .But I think if the length of Floating point value  is less than 7, it should be exact.
    Evaluating 3.1415f < 3.1415, firstly, 3.1415f will be converted to Double,this step will lead to the precision loss. 
    Try evaluating 3.1415f == 3.1415.toFloat. It is true.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org