Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

davies
Copy link
Contributor

@davies davies commented Aug 25, 2015

@SparkQA
Copy link

SparkQA commented Aug 25, 2015

Test build #41526 has finished for PR 8415 at commit 7f9b428.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@chenghao-intel
Copy link
Contributor

I've tested with some corner case, it works for me. LGTM, except the unit test itself need to update with the new scale.

@SparkQA
Copy link

SparkQA commented Aug 25, 2015

Test build #41545 has finished for PR 8415 at commit 22a966d.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

if (diff > 0) {
decDig -= diff / 2 + 1
intDig = DecimalType.MAX_SCALE - decDig
DecimalType.bounded(intDig + decDig, decDig)
Copy link
Contributor

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.

@yhuai
Copy link
Contributor

yhuai commented Aug 25, 2015

LGTM. Merging to master and branch 1.5.

asfgit pushed a commit that referenced this pull request Aug 25, 2015
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>
@asfgit asfgit closed this in 7467b52 Aug 25, 2015
intDig = DecimalType.MAX_SCALE - decDig
DecimalType.bounded(intDig + decDig, decDig)
}
val resultType = DecimalType.bounded(intDig + decDig, decDig)
val widerType = widerDecimalType(p1, s1, p2, s2)
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants