-
- Downloads
[SPARK-20786][SQL] Improve ceil and floor handle the value which is not 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 #18016 from heary-cao/ceil_long.
Showing
- sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala 4 additions, 2 deletions...ache/spark/sql/catalyst/expressions/mathExpressions.scala
- sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala 1 addition, 1 deletion...rg/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala
- sql/core/src/test/resources/sql-tests/inputs/operators.sql 14 additions, 0 deletionssql/core/src/test/resources/sql-tests/inputs/operators.sql
- sql/core/src/test/resources/sql-tests/results/operators.sql.out 80 additions, 0 deletions...re/src/test/resources/sql-tests/results/operators.sql.out
Loading
Please register or sign in to comment