GitHub user jiangxb1987 opened a pull request:
https://github.com/apache/spark/pull/15059
[SPARK-17506][SQL] Improve the check double values equality rule.
## What changes were proposed in this pull request?
In `ExpressionEvalHelper`, we check the equality between two double values
by comparing whether the expected value is within the range [target -
tolerance, target + tolerance], but this can cause a negative false when the
compared numerics are very large.
Beforeï¼
```
val1 = 1.6358558070241E306
val2 = 1.6358558070240974E306
ExpressionEvalHelper.compareResults(val1, val2)
false
```
In fact, `val1` and `val2` are but with different precisions, we should
tolerant this case by comparing with percentage range, eg.,expected is within
range [target - target * tolerance_percentage, target + target *
tolerance_percentage].
After:
```
val1 = 1.6358558070241E306
val2 = 1.6358558070240974E306
ExpressionEvalHelper.compareResults(val1, val2)
true
```
## How was this patch tested?
Exsiting testcases.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/jiangxb1987/spark deq
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/15059.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 #15059
----
commit 78f37334164a015605d5c23ff7217a131c3ea3a7
Author: jiangxingbo <[email protected]>
Date: 2016-09-12T15:14:28Z
check the equality of double values with tolerance within percentage range.
----
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]