ocean-zhc commented on code in PR #9299:
URL: https://github.com/apache/seatunnel/pull/9299#discussion_r2083987008


##########
seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/sql/zeta/ZetaSQLFunction.java:
##########
@@ -559,9 +567,34 @@ public Object executeFunctionExpr(String functionName, 
List<Object> args) {
             case YEAR:
                 return DateTimeFunction.year(args);
             case COALESCE:
-                return SystemFunction.coalesce(args);
+                // Get the first argument's type from the function's expression
+                if (currentFunction != null) {
+                    // Get the expected return type of the COALESCE function
+                    try {
+                        SeaTunnelDataType<?> targetType =
+                                zetaSQLType.getExpressionType(currentFunction);
+                        return SystemFunction.coalesce(args, targetType);

Review Comment:
   If the first argument is NULL (which is common in COALESCE and IFNULL 
functions), getting the type information from args[0] is unreliable because 
NULL itself has no specific type.



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

Reply via email to