-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-20786][SQL]Improve ceil and floor handle the value which is not expected #18016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the question is, why is it a valid long but being used as a double (?) elsewhere?
Also you can use methods on BigDecimal to query its precision and scale. toString isn't the right approach
|
+1 on Sean's comment. This is not a parser issue. Can you just fix this by adding |
|
@hvanhovell @srowen |
|
ok to test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could yo move all these new tests to the end of operators.sql?
You can run the following command to generate the result files.
SPARK_GENERATE_GOLDEN_FILES=1 build/sbt "sql/test-only *SQLQueryTestSuite"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, add new tests to the end of operators.sql.
please review it again.
thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you revert the changes you made in this file MathFunctionsSuite.scala?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK,
please review it again.
thanks.
|
Test build #77061 has finished for PR 18016 at commit
|
68ecf5e to
1f771bd
Compare
|
Test build #77073 has finished for PR 18016 at commit
|
|
Test build #77074 has finished for PR 18016 at commit
|
|
Test build #77077 has finished for PR 18016 at commit
|
|
Test build #77078 has finished for PR 18016 at commit
|
|
Test build #77083 has started for PR 18016 at commit |
|
Test build #77087 has finished for PR 18016 at commit
|
|
LGTM except one comment. |
6d8f507 to
6c50fec
Compare
|
Test build #77162 has finished for PR 18016 at commit
|
|
Test build #77163 has finished for PR 18016 at commit
|
|
Test build #77164 has finished for PR 18016 at commit
|
|
LGTM |
|
Thanks! Merging to master. Could you submit another PR to backport it to 2.2? |
…ot expected ## What changes were proposed in this pull request? spark-sql>SELECT ceil(1234567890123456); 1234567890123456 spark-sql>SELECT ceil(12345678901234567); 12345678901234568 spark-sql>SELECT ceil(123456789012345678); 123456789012345680 when the length of the getText is greater than 16. long to double will be precision loss. but mysql handle the value is ok. mysql> SELECT ceil(1234567890123456); +------------------------+ | ceil(1234567890123456) | +------------------------+ | 1234567890123456 | +------------------------+ 1 row in set (0.00 sec) mysql> SELECT ceil(12345678901234567); +-------------------------+ | ceil(12345678901234567) | +-------------------------+ | 12345678901234567 | +-------------------------+ 1 row in set (0.00 sec) mysql> SELECT ceil(123456789012345678); +--------------------------+ | ceil(123456789012345678) | +--------------------------+ | 123456789012345678 | +--------------------------+ 1 row in set (0.00 sec) ## How was this patch tested? Supplement the unit test. Author: caoxuewen <cao.xuewen@zte.com.cn> Closes apache#18016 from heary-cao/ceil_long.
|
@heary-cao Hi, I found |
|
hm guys please don’t use the end-to-end tests to test expression behavior. use unit tests which automatically tests code gen, interpreted, and different data types. |
What changes were proposed in this pull request?
spark-sql>SELECT ceil(1234567890123456);
1234567890123456
spark-sql>SELECT ceil(12345678901234567);
12345678901234568
spark-sql>SELECT ceil(123456789012345678);
123456789012345680
when the length of the getText is greater than 16. long to double will be precision loss.
but mysql handle the value is ok.
mysql> SELECT ceil(1234567890123456);
+------------------------+
| ceil(1234567890123456) |
+------------------------+
| 1234567890123456 |
+------------------------+
1 row in set (0.00 sec)
mysql> SELECT ceil(12345678901234567);
+-------------------------+
| ceil(12345678901234567) |
+-------------------------+
| 12345678901234567 |
+-------------------------+
1 row in set (0.00 sec)
mysql> SELECT ceil(123456789012345678);
+--------------------------+
| ceil(123456789012345678) |
+--------------------------+
| 123456789012345678 |
+--------------------------+
1 row in set (0.00 sec)
How was this patch tested?
Supplement the unit test.