github-actions[bot] commented on code in PR #62524:
URL: https://github.com/apache/doris/pull/62524#discussion_r3098528650


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ExpressionTrait.java:
##########
@@ -46,23 +47,58 @@ default void checkLegalityBeforeTypeCoercion() {}
     @Developing
     default void checkLegalityAfterRewrite() {}
 
+    /**
+     * getArguments.
+     */
     default List<Expression> getArguments() {
-        return children();

Review Comment:
   Unwrapping `Variable` here only fixes callers that already use 
`getArgument*()` / `getArguments*()`. A lot of function legality/signature code 
still reads raw `child()` nodes before the later `VariableToLiteral` analyzer 
rule runs, so the same user-variable bug is still present there. Concrete 
example: `SELECT UTC_TIMESTAMP(@p)` with `@p = 3` still fails, because 
`visitUnboundVariable()` returns `Variable(realExpression=literal)`, 
`visitUnboundFunction()` builds `UtcTimestamp(Variable)`, and then 
`TypeCoercionUtils.processBoundFunction()` immediately calls 
`UtcTimestamp.checkLegalityBeforeTypeCoercion()`, which rejects 
`!child(0).isLiteral()`. The same pattern exists in `utc_time`, `uniform`, 
`width_bucket`, etc. I think this needs to be fixed earlier in the 
bind/type-check path, or those raw-child checks need to be updated as well; 
otherwise this patch only fixes the `window_funnel`-style subset of functions.



##########
fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java:
##########
@@ -587,10 +589,23 @@ public void setUserVar(String name, LiteralExpr value) {
             LiteralExpr literalExpr = userVars.get(varName);
             if (literalExpr instanceof BoolLiteral) {
                 return Literal.of(((BoolLiteral) literalExpr).getValue());
-            } else if (literalExpr instanceof IntLiteral) {
+            } else if (literalExpr instanceof IntLiteral || literalExpr 
instanceof LargeIntLiteral) {
                 // the value in the IntLiteral should be int, but now is long 
in old planner literalExpr
                 // so type coercion to generate right new planner int Literal

Review Comment:
   This fix still misses the forwarded-FE path. `getLiteralForUserVar()` now 
relies on the stored legacy literal keeping its original primitive type, but 
`FEOpExecutor.getForwardUserVariables()` serializes all of 
`TINYINT/SMALLINT/INT/BIGINT` as `INT_LITERAL`, and 
`ConnectProcessor.getLiteralExprFromThrift()` reconstructs that as `new 
IntLiteral(value)` while ignoring `node.type`. So `SET @v = CAST(1 AS BIGINT)` 
executed through an observer/follower still degrades to a TINYINT before this 
method runs. `ExprToThriftVisitor` already sends `msg.type`, so the real fix 
needs to preserve that type when rebuilding the legacy `IntLiteral`; otherwise 
the integer-typing bug remains on forwarded queries.



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