Github user paul-rogers commented on the issue:
https://github.com/apache/drill/pull/517
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.
---
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.
---