Copilot commented on code in PR #51145:
URL: https://github.com/apache/doris/pull/51145#discussion_r2108065731
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ArraySum.java:
##########
@@ -68,6 +70,16 @@ public ArraySum(Expression arg) {
super("array_sum", arg);
}
+ @Override
+ public void checkLegalityBeforeTypeCoercion() {
+ DataType argType = child().getDataType();
+ if (((ArrayType) argType).getItemType().isComplexType()
+ || ((ArrayType)
argType).getItemType().isStringType()) {
+ throw new AnalysisException(toSql() + " does not support type: "
Review Comment:
The exception message uses `toSql()` which may not match the exact format
expected by the regression tests (e.g., the tests look for
`array_sum(cast(element_at(var, 'b') as ARRAY<TEXT>))`). Consider constructing
the error message based on the coerced expression or using a consistent
serialization method to align with test assertions.
```suggestion
throw new AnalysisException(child().toString() + " does not
support type: "
```
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ArraySum.java:
##########
@@ -68,6 +70,16 @@ public ArraySum(Expression arg) {
super("array_sum", arg);
}
+ @Override
+ public void checkLegalityBeforeTypeCoercion() {
Review Comment:
[nitpick] The `checkLegalityBeforeTypeCoercion` logic is duplicated across
`ArraySum`, `ArrayAvg`, and `ArrayProduct`. Consider refactoring this into a
shared utility method or a common base class to reduce duplication and simplify
future updates.
--
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]