I don't see moving the verification check here rather than doing in planning 
time helps. Since for each addition call we still increase the precision by 1, 
hence for 39 such additions precision will go beyond max allowed 38 and scale 
will become -1, hence throwing the error.

I think instead what we can do is while passing `MathContext` to BigDecimal 
pass `adjusted precision` and `Math.max(0, adjusted_scale).` This will ensure 
that negative scale is never passed in context and if the operation is not 
possible in BigDecimal under given MathContext, it should throw Exception which 
Drill can in turn throw.



[ Full content available at: https://github.com/apache/drill/pull/1451 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to