vvysotskyi commented on a change in pull request #1451: DRILL-6710: Disallow 
negative scale for VarDecimal
URL: https://github.com/apache/drill/pull/1451#discussion_r213951578
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/planner/types/decimal/DecimalScalePrecisionModFunction.java
 ##########
 @@ -40,5 +40,6 @@ public void computeScalePrecision(int leftPrecision, int 
leftScale, int rightPre
 
     // Output precision should atleast be greater or equal to the input 
precision
     outputPrecision = Math.max(outputPrecision, Math.max(leftPrecision, 
rightPrecision));
 
 Review comment:
   It was a comment which described older behavior. After deprecating old 
decimal types, there was no need in determining the range, so it was replaced 
with `DRILL_REL_DATATYPE_SYSTEM.getMaxNumericPrecision()`. But we cannot return 
precision greater than maxNumericPrecision. Or we can try to use formula from 
SQL Server implementation:
   ```
   min(p1-s1, p2 -s2) + max( s1,s2 )
   ```
   But again, add `Math.min(DRILL_REL_DATATYPE_SYSTEM.getMaxNumericPrecision(), 
outputPrecision)` to be sure that the value is not greater than 
maxNumericPrecision.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to