Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.apache.doris.catalog.Type;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.VariableMgr;
import org.apache.doris.rewrite.FEFunction;
import org.apache.doris.rewrite.FEFunctionList;
import org.apache.doris.rewrite.FEFunctions;
Expand Down Expand Up @@ -110,13 +109,7 @@ public Expr evalExpr(Expr constExpr) {
}
}
} else if (constExpr instanceof SysVariableDesc) {
try {
VariableMgr.fillValue(ConnectContext.get().getSessionVariable(), (SysVariableDesc) constExpr);
return ((SysVariableDesc) constExpr).getLiteralExpr();
} catch (AnalysisException e) {
LOG.warn("failed to get session variable value: " + ((SysVariableDesc) constExpr).getName());
return constExpr;
}
return ((SysVariableDesc) constExpr).getLiteralExpr();
}
return constExpr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ public Expr getLiteralExpr() {

@Override
public Expr getResultValue() throws AnalysisException {
Expr expr = super.getResultValue();
if (!Strings.isNullOrEmpty(name) && VariableVarConverters.hasConverter(name)) {
// Return the string type here so that it can correctly match the subsequent function signature.
// And we also set `beConverted` to session variable name in StringLiteral, so that it can be cast back
Expand All @@ -128,7 +127,7 @@ public Expr getResultValue() throws AnalysisException {
throw new AnalysisException(e.getMessage());
}
}
return expr;
return super.getResultValue();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
* Each converter should put in map (variable name -> converters) and only converts the variable with specified name.
*
* The converted session variable is a special kind of variable.
* It's real type is int, so for example, when querying `select @@sql_mode`, the return column
* type is "int".
* It's real type is Long or Int, for example, the variable `sql_mode` is Long, when querying `select @@sql_mode`,
* the return column type is String.
* But user usually set this variable by string, such as:
* `set @@sql_mode = 'STRICT_TRANS_TABLES'`
* or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void testSqlMode() throws Exception {
stmtExecutor.execute();
Expr expr = stmtExecutor.getParsedStmt().getResultExprs().get(0);
Assert.assertTrue(expr instanceof SlotRef);
Assert.assertTrue(expr.getType() == Type.BIGINT);
Assert.assertSame(expr.getType(), Type.VARCHAR);
}

@Test
Expand Down