-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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
[SPARK-10215] [SQL] Fix precision of division (follow the rule in Hive) #8415
Conversation
Test build #41526 has finished for PR 8415 at commit
|
I've tested with some corner case, it works for me. LGTM, except the unit test itself need to update with the new |
Test build #41545 has finished for PR 8415 at commit
|
if (diff > 0) { | ||
decDig -= diff / 2 + 1 | ||
intDig = DecimalType.MAX_SCALE - decDig | ||
DecimalType.bounded(intDig + decDig, decDig) |
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.
This line is not used. I will remove it when I merge the pr.
LGTM. Merging to master and branch 1.5. |
Follow the rule in Hive for decimal division. see https://github.com/apache/hive/blob/ac755ebe26361a4647d53db2a28500f71697b276/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFOPDivide.java#L113 cc chenghao-intel Author: Davies Liu <davies@databricks.com> Closes #8415 from davies/decimal_div2. (cherry picked from commit 7467b52) Signed-off-by: Yin Huai <yhuai@databricks.com>
intDig = DecimalType.MAX_SCALE - decDig | ||
DecimalType.bounded(intDig + decDig, decDig) | ||
} | ||
val resultType = DecimalType.bounded(intDig + decDig, decDig) | ||
val widerType = widerDecimalType(p1, s1, p2, s2) |
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.
is the resultType
always tighter than widerType
?
Follow the rule in Hive for decimal division. see https://github.com/apache/hive/blob/ac755ebe26361a4647d53db2a28500f71697b276/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFOPDivide.java#L113
cc @chenghao-intel