hailin0 commented on code in PR #8625:
URL: https://github.com/apache/seatunnel/pull/8625#discussion_r1948326811


##########
seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/sql/zeta/functions/NumericFunction.java:
##########
@@ -443,4 +446,52 @@ public static Number trunc(List<Object> args) {
         }
         return round(v1, v2, RoundingMode.DOWN);
     }
+
+    public static Object max(List<Object> args) {

Review Comment:
   ```suggestion
       public static Object arrayMax(List<Object> args) {
   ```



##########
seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/sql/zeta/functions/NumericFunction.java:
##########
@@ -443,4 +446,52 @@ public static Number trunc(List<Object> args) {
         }
         return round(v1, v2, RoundingMode.DOWN);
     }
+
+    public static Object max(List<Object> args) {
+        if (args == null || args.isEmpty()) {
+            return null;
+        }
+        Object[] dataList = (Object[]) args.get(0);
+        if (dataList == null || dataList.length == 0) {
+            return null;
+        }
+        if (dataList[0] instanceof String) {
+            return Arrays.stream(dataList)
+                    .map(String.class::cast)
+                    .max(String::compareTo)
+                    .orElse(null);
+        } else if (dataList[0] instanceof Number) {
+            return Arrays.stream(dataList)
+                    .map(Number.class::cast)
+                    .max(Comparator.comparingDouble(Number::doubleValue))
+                    .orElse(null);
+        }
+        throw new TransformException(
+                CommonErrorCode.UNSUPPORTED_DATA_TYPE,
+                String.format("Unsupported function max() arguments: %s", 
args));
+    }
+
+    public static Object min(List<Object> args) {

Review Comment:
   ```suggestion
       public static Object arrayMin(List<Object> args) {
   ```



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