Skip to content

Commit 14049f2

Browse files
authored
[Bug]Fix variable can`t throw error (DataLinkDC#4115)
1 parent f6ec846 commit 14049f2

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

dinky-core/src/main/java/org/dinky/executor/VariableManager.java

+14-18
Original file line numberDiff line numberDiff line change
@@ -134,25 +134,21 @@ public Object getVariable(String variableName) {
134134
checkArgument(
135135
!StringUtils.isNullOrWhitespaceOnly(variableName),
136136
"sql variable name or jexl key cannot be null or empty.");
137-
try {
138-
if (variables.containsKey(variableName)) {
139-
return variables.get(variableName);
140-
}
141-
// load expression variable class
142-
if (parseAndMatchExpressionVariable(variableName)) {
143-
return ENGINE.eval(variableName, EngineContextHolder.getEngineContext(), null);
144-
}
145-
return null;
146-
} catch (Exception e) {
147-
String error = format(
148-
"The variable name or jexl key of sql \"${%s}\" does not exist.\n"
149-
+ "Please follow the following methods to resolve the problem:\n"
150-
+ "1. global variables are enabled ? \n"
151-
+ "2. variable is exists ? it`s defined in sql ? or global variable is defined ? \n"
152-
+ "3. If it is a custom function variable, please check whether the class is loaded correctly",
153-
variableName);
154-
throw new BusException(error);
137+
if (variables.containsKey(variableName)) {
138+
return variables.get(variableName);
139+
}
140+
// load expression variable class
141+
if (parseAndMatchExpressionVariable(variableName)) {
142+
return ENGINE.eval(variableName, EngineContextHolder.getEngineContext(), null);
155143
}
144+
String error = format(
145+
"The variable name or jexl key of sql \"${%s}\" does not exist.\n"
146+
+ "Please follow the following methods to resolve the problem:\n"
147+
+ "1. global variables are enabled ? \n"
148+
+ "2. variable is exists ? it`s defined in sql ? or global variable is defined ? \n"
149+
+ "3. If it is a custom function variable, please check whether the class is loaded correctly",
150+
variableName);
151+
throw new BusException(error);
156152
}
157153

158154
public boolean parseAndMatchExpressionVariable(String variableName) {

0 commit comments

Comments
 (0)