lgbo-ustc commented on code in PR #10125:
URL: 
https://github.com/apache/incubator-gluten/pull/10125#discussion_r2218126471


##########
gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/functions/BaseRexCallConverters.java:
##########
@@ -97,9 +109,89 @@ public ValidationResult isSuitable(RexCall callNode, 
RexConversionContext contex
   @Override
   public TypedExpr toTypedExpr(RexCall callNode, RexConversionContext context) 
{
     List<TypedExpr> params = getParams(callNode, context);
-    // If types are different, align them
-    List<TypedExpr> alignedParams = 
TypeUtils.promoteTypeForArithmeticExpressions(params);
+
     Type resultType = getResultType(callNode);
+    if (params.size() == 2) {
+      Type leftType = params.get(0).getReturnType();
+      Type rightType = params.get(1).getReturnType();
+
+      if (leftType instanceof DecimalType || rightType instanceof DecimalType) 
{
+        List<TypedExpr> alignedParams = 
TypeUtils.promoteTypeForArithmeticExpressions(params);
+
+        Type alignedLeftType = alignedParams.get(0).getReturnType();
+        Type alignedRightType = alignedParams.get(1).getReturnType();
+
+        if (alignedLeftType instanceof DecimalType && alignedRightType 
instanceof DecimalType) {
+          Type veloxResultType =
+              calculateDecimalResultType(
+                  (DecimalType) alignedLeftType, (DecimalType) 
alignedRightType, functionName);
+          TypedExpr veloxExpr = new CallTypedExpr(veloxResultType, 
alignedParams, functionName);
+
+          return new CallTypedExpr(resultType, List.of(veloxExpr), "cast");
+        }
+      }
+    }
+
+    List<TypedExpr> alignedParams = 
TypeUtils.promoteTypeForArithmeticExpressions(params);
     return new CallTypedExpr(resultType, alignedParams, functionName);
   }
+
+  private Type calculateDecimalResultType(

Review Comment:
   Hi, @yuanhang-dev , Sorry for the late response to this PR - I was on 
vacation. I submit a PR #10218 about decimal before see this.  I seems we don't 
need to calculate the result decimal type if we can cast integer and long into 
decimal  properly



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to