Increase output scale for decimal division#4640
Increase output scale for decimal division#4640tustvold wants to merge 2 commits intoapache:masterfrom
Conversation
|
This covers the first part of the rules but will quickly reach overflow if you combine operations without using the second rules to reduce scale: |
|
@westonpace I'm having a hard time following the logic behind adjustScaleIfNeeded. I can understand truncating the scale of the output in order to make it fit, however, the MIN_ADJUSTED_SCALE part doesn't make sense to me. It acts to clamp the scale to be <= 6, but without this having an impact on the output precision, which seems to be incorrect? Say the output had a scale of 10 and a precision of 40, adjustScaleIfNeeded would then clamp this to a scale of 6 and a precision of 38. I would have thought it would either clamp to a scale of 8 and precision of 38, or a scale of 6 and a precision of 36? Edit: oh no nvm, brain fart. It exists for the case of a scale of 5 and a precision of 40, it will refuse to reduce the scale further. This does mean that such an operation could still overflow though. |
|
I've filed #4664 and have a preliminary implementation of what it would take to support precision-loss decimal arithmetic. I hope to polish this up over the coming week |
|
Decided to not move forward with this, see #4664 (comment) |
Which issue does this PR close?
Closes #.
Rationale for this change
apache/datafusion#6828
What changes are included in this PR?
Are there any user-facing changes?
Honestly not sure, this does change the output types for some decimal arithmetic, whether that counts as a breaking change is potentially debatable given this is not something documented, and regardless is a very recent feature addition.