vvysotskyi commented on a change in pull request #1451: DRILL-6710: Drill C++ 
Client does not handle scale = 0 properly for d…
URL: https://github.com/apache/drill/pull/1451#discussion_r213592266
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/expr/ExpressionTreeMaterializer.java
 ##########
 @@ -430,19 +430,18 @@ public LogicalExpression visitFunctionCall(FunctionCall 
call, FunctionLookupCont
           }
         }
 
-        FunctionHolderExpression funcExpr = 
matchedFuncHolder.getExpr(call.getName(), argsWithCast, call.getPosition());
-        MajorType funcExprMajorType = funcExpr.getMajorType();
-        if 
(DecimalUtility.isObsoleteDecimalType(funcExprMajorType.getMinorType())) {
-          MajorType majorType =
-              MajorType.newBuilder()
-                  .setMinorType(MinorType.VARDECIMAL)
-                  .setMode(funcExprMajorType.getMode())
-                  .setScale(funcExprMajorType.getScale())
-                  .setPrecision(funcExprMajorType.getPrecision())
-                  .build();
-          return addCastExpression(funcExpr, majorType, functionLookupContext, 
errorCollector);
+        try {
+          FunctionHolderExpression funcExpr = 
matchedFuncHolder.getExpr(call.getName(), argsWithCast, call.getPosition());
+          MajorType funcExprMajorType = funcExpr.getMajorType();
+          if 
(DecimalUtility.isObsoleteDecimalType(funcExprMajorType.getMinorType())) {
+            MajorType majorType = 
MajorType.newBuilder().setMinorType(MinorType.VARDECIMAL).setMode(funcExprMajorType.getMode()).setScale(funcExprMajorType.getScale()).setPrecision(funcExprMajorType.getPrecision()).build();
+            return addCastExpression(funcExpr, majorType, 
functionLookupContext, errorCollector);
+          }
+          return funcExpr;
+        } catch (Exception ex) {
 
 Review comment:
   Could you please narrow `Exception`  to `IllegalArgumentException` here and 
add a comment that this exception may appear during constructing 
`FunctionHolderExpression` when the function return type has an invalid scale 
or precision.
   
   Also, please restore initial formatting above for `MajorType majorType`.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to