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


##########
fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java:
##########
@@ -88,6 +88,7 @@
 import org.xnio.StreamConnection;
 
 import java.io.IOException;
+import java.math.BigInteger;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Collections;

Review Comment:
   Blocking: this `LARGEINT` arm is unreachable in the actual user-variable 
flow. `SetUserDefinedVarOp.run()` stores values via `value.toLegacyLiteral()`, 
and a Nereids `LargeIntLiteral` becomes 
`org.apache.doris.analysis.LargeIntLiteral`, not `IntLiteral`. That means `SET 
@v = 9223372036854775808` still falls through to the final `else` here and is 
converted to a string literal instead of a Nereids `LargeIntLiteral`. Please 
handle legacy `LargeIntLiteral` explicitly (or reuse 
`Literal.fromLegacyLiteral(literalExpr, literalExpr.getType())` for the numeric 
branches).`



##########
fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/UserVariableAnalysisTest.java:
##########
@@ -0,0 +1,96 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.rules.analysis;
+
+import org.apache.doris.analysis.IntLiteral;
+import org.apache.doris.nereids.CascadesContext;
+import org.apache.doris.nereids.analyzer.UnboundVariable;
+import org.apache.doris.nereids.analyzer.UnboundVariable.VariableType;
+import org.apache.doris.nereids.rules.expression.ExpressionRewriteContext;
+import org.apache.doris.nereids.trees.expressions.ComparisonPredicate;
+import org.apache.doris.nereids.trees.expressions.EqualTo;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.Variable;
+import org.apache.doris.nereids.trees.expressions.literal.IntegerLiteral;
+import org.apache.doris.nereids.trees.expressions.literal.Literal;
+import org.apache.doris.nereids.types.BigIntType;
+import org.apache.doris.nereids.types.IntegerType;
+import org.apache.doris.nereids.util.MemoTestUtils;
+import org.apache.doris.qe.ConnectContext;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+/** Tests for user variable handling in expression analysis. */
+public class UserVariableAnalysisTest {
+
+    @Test
+    public void testUserVarIntegerTypeSmall() {
+        ConnectContext ctx = MemoTestUtils.createConnectContext();
+        // set user var @a = 1 (small int)
+        ctx.setUserVar("a", new IntLiteral(1L));
+
+        // get nereids literal via ConnectContext helper
+        Literal l = ConnectContext.get().getLiteralForUserVar("a");
+        Assertions.assertNotNull(l);
+        Assertions.assertEquals(IntegerType.INSTANCE, l.getDataType());
+    }
+
+    @Test
+    public void testUserVarIntegerTypeBig() {

Review Comment:
   `Long.MAX_VALUE` is still a legacy `IntLiteral` with `BIGINT` type, so this 
test never exercises the newly added `LARGEINT` path. Please add a case using a 
real legacy `org.apache.doris.analysis.LargeIntLiteral` (for example 
`"9223372036854775808"`), otherwise the remaining bug in 
`getLiteralForUserVar()` will not be caught.



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