Github user paul-rogers commented on the issue:

    https://github.com/apache/drill/pull/517
  
    The plot thickens. I tried the fix of setting the precision to a constant 
of 10. This uncovered a larger issue. The template in question generates cast 
functions for (INTEGER, BIGINT) x (DECIMAL9, DECIMAL18, DECIMAL28) and perhaps 
others. The constant of 10 does not, of course, work for BIGINT (long) values.
    
    The trick is that precision=10 won't work for DECIMAL9 either. Dave's 
solution has a similar problem. Dave sets the precision to whatever is right 
for the input value, which seems great. But, that value could be too large for 
the output DECIMAL type.
    
    What we need is to set the precision to the min( max int precision, max 
decimal precision ). Or, if we use Dave's proposed solution, max( input arg 
precision, max decimal precision ).
    
    In either case, the code must handle overflow. Passing a Long.MAX_VALUE or 
even Integer.MAX_VALUE to CastBigIntDecimal9( ) should cause an overflow error 
or data truncation. I'll research how that worked previously to see if we've 
uncovered a new issue, or if a solution already exists.


---
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.
---

Reply via email to