github-actions[bot] commented on code in PR #62524:
URL: https://github.com/apache/doris/pull/62524#discussion_r3115050448
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Random.java:
##########
@@ -97,7 +97,7 @@ private Random(UniqueFunctionParams functionParams) {
public void checkLegalityBeforeTypeCoercion() {
// align with original planner behavior, refer to:
// org/apache/doris/analysis/Expr.getBuiltinFunction()
- for (Expression child : children()) {
+ for (Expression child : getArguments()) {
Review Comment:
This still leaves `rand(@v)` / `random(@v)` broken. `BuiltinFunctionBuilder`
instantiates the public `Random(Expression arg)` constructor before
`processBoundFunction()` reaches this method, and that constructor still
enforces `arg instanceof Literal`. So a variable-backed literal still fails on
the raw `Variable` object before this new `getArguments()` path ever runs. The
constructor path needs the same resolved-argument handling, or the literal
check needs to move out of the constructor entirely.
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StructElement.java:
##########
@@ -58,11 +58,13 @@ private StructElement(ScalarFunctionParams functionParams) {
@Override
public void checkLegalityBeforeTypeCoercion() {
- if (!(child(0).getDataType() instanceof StructType
- || child(0).getDataType() instanceof NullType)) {
+ Expression structArgument = getArgument(0);
+ Expression fieldArgument = getArgument(1);
+ if (!(structArgument.getDataType() instanceof StructType
+ || structArgument.getDataType() instanceof NullType)) {
SearchSignature.throwCanNotFoundFunctionException(this.getName(),
this.getArguments());
}
- if (!(child(1) instanceof StringLikeLiteral || child(1) instanceof
IntegerLikeLiteral)) {
+ if (!(fieldArgument instanceof StringLikeLiteral || fieldArgument
instanceof IntegerLikeLiteral)) {
Review Comment:
This only fixes the early legality check. `getSignatures()` below still
dispatches on raw `child(1)` and computes the return type from that raw node,
while `BoundFunction.getSignature()` is invoked immediately after
`checkLegalityBeforeTypeCoercion()` in `processBoundFunction()`, before
`VariableToLiteral` runs. So `struct_element(..., @field_name)` and
`struct_element(..., @idx)` still fall into the final `AnalysisException` path
instead of using the variable real literal. The return-type/signature path
needs to use `getArgument(...)` consistently too.
--
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]