Uh oh!
There was an error while loading. Please reload this page.
[SPARK-20665][SQL]"Bround" and "Round" function return NULL - #17906
[SPARK-20665][SQL]"Bround" and "Round" function return NULL#1790610110346 wants to merge 2 commits into
Conversation
dongjoon-hyun
commented
May 9, 2017
Hi, @10110346 . |
"round" has the same problem. @dongjoon-hyun . Actually, this PR can solve the problem for both of them |
dongjoon-hyun
commented
May 10, 2017
Then, let's change the title and description of this PR and the JIRA. |
10110346
commented
May 10, 2017
ok, i will do it, thanks @dongjoon-hyun |
f5ef3e7 to
b76f802Compare10110346
commented
May 10, 2017
Please reveiw it,thanks @dongjoon-hyun@cloud-fan |
| BigDecimal(3.142), BigDecimal(3.1416), BigDecimal(3.14159), | ||
| BigDecimal(3.141593), BigDecimal(3.1415927)) | ||
| // round_scale > current_scale would result in precision increase | ||
| // and not allowed by o.a.s.s.types.Decimal.changePrecision, therefore null |
There was a problem hiding this comment.
seems we are changing the behavior, can you check with other database and see if it's expected to return the original value for this case?
@cloud-fan Also,I tested in spark1.4, as follows:
|
cloud-fan
commented
May 11, 2017
LGTM, cc @gatorsmile to double check |
gatorsmile
commented
May 11, 2017
ok to test |
gatorsmile
commented
May 11, 2017
Yeah. This is a right fix. I checked Hive and it behaves the same. Before the fix, we return a wrong result. |
| checkAnswer( | ||
| sql(s"SELECT bround($bdPi, 7), bround($bdPi, 8), bround($bdPi, 9), bround($bdPi, 10), " + | ||
| s"bround($bdPi, 100), bround($bdPi, 6), bround(null, 8)"), | ||
| Seq(Row(bdPi, bdPi, bdPi, bdPi, bdPi, BigDecimal("3.141592"), null)) |
There was a problem hiding this comment.
How about moving the test case to SQLQueryTestSuite and create a new file mathFunctions.sql. You can refer to s.c.s.t.resources/sql-tests/inputs/cast.sql. To generate the result file, you can run the following command:
SPARK_GENERATE_GOLDEN_FILES=1 build/sbt "sql/test-only *SQLQueryTestSuite"
SparkQA
commented
May 11, 2017
Test build #76820 has finished for PR 17906 at commit
|
dongjoon-hyun
commented
May 11, 2017
Retest this please. |
SparkQA
commented
May 11, 2017
Test build #76832 has finished for PR 17906 at commit
|
cloud-fan
commented
May 12, 2017
hi @10110346 , can you set the |
10110346
commented
May 12, 2017
@cloud-fan ok, I will do it |
10110346
commented
May 12, 2017
@cloud-fan Spark 2.0 and Spark 2.1 have the same issue. I have updated the affected versions in the JIRA. Thanks! |
## What changes were proposed in this pull request? spark-sql>select bround(12.3, 2); spark-sql>NULL For this case, the expected result is 12.3, but it is null. So ,when the second parameter is bigger than "decimal.scala", the result is not we expected. "round" function has the same problem. This PR can solve the problem for both of them. ## How was this patch tested? unit test cases in MathExpressionsSuite and MathFunctionsSuite Author: liuxian <liu.xian3@zte.com.cn> Closes#17906 from 10110346/wip_lx_0509. (cherry picked from commit 2b36eb6) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
spark-sql>select bround(12.3, 2); spark-sql>NULL For this case, the expected result is 12.3, but it is null. So ,when the second parameter is bigger than "decimal.scala", the result is not we expected. "round" function has the same problem. This PR can solve the problem for both of them. unit test cases in MathExpressionsSuite and MathFunctionsSuite Author: liuxian <liu.xian3@zte.com.cn> Closes#17906 from 10110346/wip_lx_0509. (cherry picked from commit 2b36eb6) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
cloud-fan
commented
May 12, 2017
thanks, merging to master/2.2/2.1/2.0! |
spark-sql>select bround(12.3, 2); spark-sql>NULL For this case, the expected result is 12.3, but it is null. So ,when the second parameter is bigger than "decimal.scala", the result is not we expected. "round" function has the same problem. This PR can solve the problem for both of them. unit test cases in MathExpressionsSuite and MathFunctionsSuite Author: liuxian <liu.xian3@zte.com.cn> Closes#17906 from 10110346/wip_lx_0509. (cherry picked from commit 2b36eb6) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
## What changes were proposed in this pull request? spark-sql>select bround(12.3, 2); spark-sql>NULL For this case, the expected result is 12.3, but it is null. So ,when the second parameter is bigger than "decimal.scala", the result is not we expected. "round" function has the same problem. This PR can solve the problem for both of them. ## How was this patch tested? unit test cases in MathExpressionsSuite and MathFunctionsSuite Author: liuxian <liu.xian3@zte.com.cn> Closesapache#17906 from 10110346/wip_lx_0509.
## What changes were proposed in this pull request? spark-sql>select bround(12.3, 2); spark-sql>NULL For this case, the expected result is 12.3, but it is null. So ,when the second parameter is bigger than "decimal.scala", the result is not we expected. "round" function has the same problem. This PR can solve the problem for both of them. ## How was this patch tested? unit test cases in MathExpressionsSuite and MathFunctionsSuite Author: liuxian <liu.xian3@zte.com.cn> Closesapache#17906 from 10110346/wip_lx_0509.
## What changes were proposed in this pull request? add test case to MathExpressionsSuite as apache#17906 ## How was this patch tested? unit test cases Author: liuxian <liu.xian3@zte.com.cn> Closesapache#18082 from 10110346/wip-lx-0524.
spark-sql>select bround(12.3, 2); spark-sql>NULL For this case, the expected result is 12.3, but it is null. So ,when the second parameter is bigger than "decimal.scala", the result is not we expected. "round" function has the same problem. This PR can solve the problem for both of them. unit test cases in MathExpressionsSuite and MathFunctionsSuite Author: liuxian <liu.xian3@zte.com.cn> Closesapache#17906 from 10110346/wip_lx_0509. (cherry picked from commit 2b36eb6) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
What changes were proposed in this pull request?
spark-sql>select bround(12.3, 2);
spark-sql>NULL
For this case, the expected result is 12.3, but it is null.
So ,when the second parameter is bigger than "decimal.scala", the result is not we expected.
"round" function has the same problem. This PR can solve the problem for both of them.
How was this patch tested?
unit test cases in MathExpressionsSuite and MathFunctionsSuite