Github user daveoshinsky commented on the issue:
https://github.com/apache/drill/pull/517
The scale is a schema-level property of that column of data, that is never
changed on the fly, to deal with problematic truncation, or otherwise. Â If
anybody is interested in a detail explanation, or other tidbits about how
decimal types work, just let me know ([email protected]).
On Saturday, August 6, 2016 3:27 PM, Paul Rogers
<[email protected]> wrote:
To clarify the previous comment... In the case where the maximum required
precision for the int type is greater than the maximum precision of the target
decimal type, we use Dave's code to figure out the actual precision of the int
value. Then, we figure out scale as:scale = value precision - max decimal
precision
This, if you try to store 123,456,789,012 into an Dec9, you would get
123,456,789,000 (truncate the lower-order digits.) The solution does not handle
rounding, but that can be added.Note that the decision to use Dave's code would
be in the template: it would apply for, say, BigInt to Dec9 and that kind of
thing. The logic to detect this case is already in the suggested code snippet.
<#if inPrec < maxPrec>
...
<#else>
// Put Dave's find-the-precision logic here
if ( out.precision > ${maxPrec} ) {
out.scale = out.precision - ${maxPrec};
out.precision = ${maxPrec};
}
</#endif>
I have not tested the above; it is just a pseudocode suggestion. â
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---