PHILO-HE commented on code in PR #10125:
URL: 
https://github.com/apache/incubator-gluten/pull/10125#discussion_r2238199027


##########
gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/TypeUtils.java:
##########
@@ -52,25 +49,24 @@ public static boolean isStringType(Type type) {
     return type instanceof VarCharType;
   }
 
-  public static List<TypedExpr> 
promoteTypeForArithmeticExpressions(List<TypedExpr> expressions) {
-    Type targetType =
-        expressions.stream()
-            .map(
-                expr -> {
-                  Type returnType = expr.getReturnType();
-                  int priority = getNumericTypePriority(returnType);
-                  return new Tuple2<>(priority, returnType);
-                })
-            .max((t1, t2) -> Integer.compare(t1.f0, t2.f0))
-            .orElseThrow(() -> new RuntimeException("No expressions found"))
-            .f1;
+  public static TypedExpr[] promoteTypeForArithmeticExpressions(

Review Comment:
   Keep using `List<TypedExpr>` as return type.



##########
gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/functions/ModRexCallConverter.java:
##########
@@ -55,9 +56,10 @@ public ValidationResult isSuitable(RexCall callNode, 
RexConversionContext contex
   @Override
   public TypedExpr toTypedExpr(RexCall callNode, RexConversionContext context) 
{
     List<TypedExpr> params = getParams(callNode, context);
-    List<TypedExpr> alignedParams = 
TypeUtils.promoteTypeForArithmeticExpressions(params);
+    TypedExpr[] alignedParams =
+        TypeUtils.promoteTypeForArithmeticExpressions(params.get(0), 
params.get(1));
     // Use the divisor's type as the result type
-    Type resultType = params.get(1).getReturnType();
-    return new CallTypedExpr(resultType, params, functionName);
+    Type resultType = alignedParams[0].getReturnType();

Review Comment:
   Please remove the above inconsistent comment.



##########
gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/functions/BaseRexCallConverters.java:
##########
@@ -62,6 +63,16 @@ public DefaultRexCallConverter(String functionName) {
   public TypedExpr toTypedExpr(RexCall callNode, RexConversionContext context) 
{
     List<TypedExpr> params = getParams(callNode, context);
     Type resultType = getResultType(callNode);
+
+    if ("cast".equals(functionName) && params.size() == 1) {
+      TypedExpr sourceExpr = params.get(0);
+      Type sourceType = sourceExpr.getReturnType();
+
+      if (sourceType instanceof TimestampType && resultType instanceof 
TimestampType) {

Review Comment:
   For any cast between two same types, seems nothing needs to be done, but 
just return source expr?



##########
gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/functions/ModRexCallConverter.java:
##########
@@ -27,6 +27,7 @@
 
 import org.apache.calcite.rex.RexCall;
 
+import java.util.Arrays;
 import java.util.List;
 
 public class ModRexCallConverter extends BaseRexCallConverter {

Review Comment:
   Seems this class can extend `BasicArithmeticOperatorRexCallConverter` to 
reuse its `isSuitable`. If `toTypedExpr` method is really different in getting 
result type, just override this method in `ModRexCallConverter`.



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