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


##########
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:
   Velox supports decimal-type calculations. If the result type does not match 
Flink's, an exception will be thrown.



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