Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

[NSE-130] fix precision loss in divide w/ decimal type #164

Merged
merged 1 commit into from
Mar 15, 2021

Conversation

rui-mo
Copy link
Collaborator

@rui-mo rui-mo commented Mar 15, 2021

What changes were proposed in this pull request?

This pr fixes precision loss in divide by using resType from CheckOverflow.
#130

How was this patch tested?

locally tested

@github-actions
Copy link

#130

convertBoundRefToAttrRef = convertBoundRefToAttrRef),
expr)
} else {
// CheckOverflow[Divide]: pass resType to Divide to avoid precision loss
Copy link
Collaborator

@zhouyuan zhouyuan Mar 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this mean divide must have a checkoverflow wrapper in spark?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look like yes for decimal divide. Below is spark code from spark/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/DecimalPrecision.scala
CheckOverflow(Divide(promotePrecision(e1, widerType), promotePrecision(e2, widerType)), resultType, nullOnOverflow)

@rui-mo
Copy link
Collaborator Author

rui-mo commented Mar 15, 2021

verified on TPC-DS

@zhouyuan zhouyuan changed the title [NSE-130] fix precision loss in divide [NSE-130] fix precision loss in divide w/ decimal type Mar 15, 2021
@zhouyuan zhouyuan merged commit 5e89cd3 into oap-project:master Mar 15, 2021
@github-actions
Copy link


@rui-mo rui-mo deleted the fix_precision branch July 13, 2021 08:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants