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 @@ -61,7 +61,8 @@ public enum ErrorCode {
ERR_NOT_ALLOWED_COMMAND(1148, new byte[]{'4', '2', '0', '0', '0'}, "The used command is not allowed"
+ " with this MySQL version"),
ERR_WRONG_COLUMN_NAME(1166, new byte[]{'4', '2', '0', '0', '0'}, "Incorrect column name '%s'. Column regex is '%s'"),
ERR_UNKNOWN_SYSTEM_VARIABLE(1193, new byte[]{'H', 'Y', '0', '0', '0'}, "Unknown system variable '%s'"),
ERR_UNKNOWN_SYSTEM_VARIABLE(1193, new byte[]{'H', 'Y', '0', '0', '0'}, "Unknown system variable '%s',"
+ "the similar variables are %s"),
ERR_BAD_SLAVE(1200, new byte[]{'H', 'Y', '0', '0', '0'}, "The server is not configured as slave; fix in config "
+ "file or with CHANGE MASTER TO"),
ERR_MASTER_INF(1201, new byte[]{'H', 'Y', '0', '0', '0'}, "Could not initialize master info structure; more error"
Expand Down
16 changes: 15 additions & 1 deletion fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.lang3.SerializationUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.similarity.JaroWinklerDistance;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
Expand All @@ -59,6 +61,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringJoiner;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
Expand Down Expand Up @@ -287,12 +290,23 @@ public static void setVar(SessionVariable sessionVariable, SetVar setVar)
throws DdlException {
VarContext varCtx = getVarContext(setVar.getVariable());
if (varCtx == null) {
ErrorReport.reportDdlException(ErrorCode.ERR_UNKNOWN_SYSTEM_VARIABLE, setVar.getVariable());
ErrorReport.reportDdlException(ErrorCode.ERR_UNKNOWN_SYSTEM_VARIABLE, setVar.getVariable(),
findSimilarSessionVarNames(setVar.getVariable()));
}
checkUpdate(setVar, varCtx.getFlag());
setVarInternal(sessionVariable, setVar, varCtx);
}

public static String findSimilarSessionVarNames(String inputName) {
JaroWinklerDistance jaroWinklerDistance = new JaroWinklerDistance();
StringJoiner joiner = new StringJoiner(", ", "{", "}");
ctxByDisplayVarName.keySet().stream()
.sorted(Comparator.comparingDouble(
s -> jaroWinklerDistance.apply(StringUtils.upperCase(s), StringUtils.upperCase(inputName))))
.limit(3).map(e -> "'" + e + "'").forEach(joiner::add);
return joiner.toString();
}

// The only difference between setVar and setVarForNonMasterFE
// is that setVarForNonMasterFE will just return if "checkUpdate" throw exception.
// This is because, when setting global variables from Non Master FE, Doris will do following step:
Expand Down