Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore](config) support select experimental session variable #31837

Merged
merged 2 commits into from
Mar 11, 2024
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
26 changes: 16 additions & 10 deletions fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,10 @@ private static void checkUpdate(SetVar setVar, int flag) throws DdlException {
// setVar: variable information that needs to be set
public static void setVar(SessionVariable sessionVariable, SetVar setVar)
throws DdlException {
VarContext varCtx = setVarPreCheck(setVar);
VarContext varCtx = getVarContext(setVar.getVariable());
if (varCtx == null) {
ErrorReport.reportDdlException(ErrorCode.ERR_UNKNOWN_SYSTEM_VARIABLE, setVar.getVariable());
}
checkUpdate(setVar, varCtx.getFlag());
setVarInternal(sessionVariable, setVar, varCtx);
}
Expand All @@ -299,7 +302,10 @@ public static void setVar(SessionVariable sessionVariable, SetVar setVar)
// So in this case, we should just ignore this exception and return.
public static void setVarForNonMasterFE(SessionVariable sessionVariable, SetVar setVar)
throws DdlException {
VarContext varCtx = setVarPreCheck(setVar);
VarContext varCtx = getVarContext(setVar.getVariable());
if (varCtx == null) {
ErrorReport.reportDdlException(ErrorCode.ERR_UNKNOWN_SYSTEM_VARIABLE, setVar.getVariable());
}
try {
checkUpdate(setVar, varCtx.getFlag());
} catch (DdlException e) {
Expand All @@ -311,9 +317,9 @@ public static void setVarForNonMasterFE(SessionVariable sessionVariable, SetVar
setVarInternal(sessionVariable, setVar, varCtx);
}

@NotNull
private static VarContext setVarPreCheck(SetVar setVar) throws DdlException {
String varName = setVar.getVariable();
@Nullable
private static VarContext getVarContext(String name) {
String varName = name;
boolean hasExpPrefix = false;
if (varName.startsWith(VariableAnnotation.EXPERIMENTAL.getPrefix())) {
varName = varName.substring(VariableAnnotation.EXPERIMENTAL.getPrefix().length());
Expand All @@ -325,13 +331,13 @@ private static VarContext setVarPreCheck(SetVar setVar) throws DdlException {
}
VarContext ctx = ctxByVarName.get(varName);
if (ctx == null) {
ErrorReport.reportDdlException(ErrorCode.ERR_UNKNOWN_SYSTEM_VARIABLE, setVar.getVariable());
return null;
}
// for non-matched prefix, report an error
VariableAnnotation varType = ctx.getField().getAnnotation(VarAttr.class).varType();
if (hasExpPrefix && (!setVar.getVariable().startsWith(varType.getPrefix())
if (hasExpPrefix && (!name.startsWith(varType.getPrefix())
|| varType == VariableAnnotation.NONE)) {
ErrorReport.reportDdlException(ErrorCode.ERR_UNKNOWN_SYSTEM_VARIABLE, setVar.getVariable());
return null;
}
return ctx;
}
Expand Down Expand Up @@ -533,7 +539,7 @@ public static void replayGlobalVariableV2(GlobalVarPersistInfo info) throws DdlE

// Get variable value through variable name, used to satisfy statement like `SELECT @@comment_version`
public static void fillValue(SessionVariable var, VariableExpr desc) throws AnalysisException {
VarContext ctx = ctxByVarName.get(desc.getName());
VarContext ctx = getVarContext(desc.getName());
if (ctx == null) {
ErrorReport.reportAnalysisException(ErrorCode.ERR_UNKNOWN_SYSTEM_VARIABLE, desc.getName());
}
Expand Down Expand Up @@ -621,7 +627,7 @@ public static String getValue(SessionVariable var, VariableExpr desc) throws Ana

// For Nereids optimizer
public static @Nullable Literal getLiteral(SessionVariable var, String name, SetType setType) {
VarContext ctx = ctxByVarName.get(name);
VarContext ctx = getVarContext(name);
if (ctx == null) {
return null;
}
Expand Down
5 changes: 5 additions & 0 deletions regression-test/suites/nereids_syntax_p0/system_var.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ suite("nereids_sys_var") {
sql "select @@session.enable_nereids_planner"
result ([[true]])
}

test {
sql "select @@session.experimental_enable_nereids_planner"
result ([[true]])
}
}
Loading