Unverified Commit 39324f50 authored by gaoyan's avatar gaoyan Committed by GitHub

[Bug] Fix vaible parse err missing tips (#3316)

parent bb7106d8
...@@ -27,7 +27,7 @@ import org.dinky.assertion.Asserts; ...@@ -27,7 +27,7 @@ import org.dinky.assertion.Asserts;
import org.dinky.constant.FlinkSQLConstant; import org.dinky.constant.FlinkSQLConstant;
import org.dinky.context.EngineContextHolder; import org.dinky.context.EngineContextHolder;
import org.dinky.data.constant.CommonConstant; import org.dinky.data.constant.CommonConstant;
import org.dinky.data.exception.DinkyException; import org.dinky.data.exception.BusException;
import org.apache.flink.table.api.DataTypes; import org.apache.flink.table.api.DataTypes;
import org.apache.flink.table.api.Table; import org.apache.flink.table.api.Table;
...@@ -144,7 +144,14 @@ public final class VariableManager { ...@@ -144,7 +144,14 @@ public final class VariableManager {
} }
return null; return null;
} catch (Exception e) { } catch (Exception e) {
throw new DinkyException(format("The variable name or jexl key of sql %s does not exist.", variableName)); String error = format(
"The variable name or jexl key of sql \"${%s}\" does not exist.\n"
+ "Please follow the following methods to resolve the problem:\n"
+ "1. global variables are enabled ? \n"
+ "2. variable is exists ? it`s defined in sql ? or global variable is defined ? \n"
+ "3. If it is a custom function variable, please check whether the class is loaded correctly",
variableName);
throw new BusException(error);
} }
} }
......
...@@ -198,10 +198,19 @@ public class Explainer { ...@@ -198,10 +198,19 @@ public class Explainer {
public ExplainResult explainSql(String statement) { public ExplainResult explainSql(String statement) {
log.info("Start explain FlinkSQL..."); log.info("Start explain FlinkSQL...");
JobParam jobParam = pretreatStatements(SqlUtil.getStatements(statement)); JobParam jobParam;
List<SqlExplainResult> sqlExplainRecords = new ArrayList<>(); List<SqlExplainResult> sqlExplainRecords = new ArrayList<>();
int index = 1; int index = 1;
boolean correct = true; boolean correct = true;
try {
jobParam = pretreatStatements(SqlUtil.getStatements(statement));
} catch (Exception e) {
SqlExplainResult.Builder resultBuilder = SqlExplainResult.Builder.newBuilder();
resultBuilder.error(e.getMessage()).parseTrue(false);
sqlExplainRecords.add(resultBuilder.build());
log.error("failed pretreatStatements:", e);
return new ExplainResult(false, sqlExplainRecords.size(), sqlExplainRecords);
}
for (StatementParam item : jobParam.getDdl()) { for (StatementParam item : jobParam.getDdl()) {
SqlExplainResult.Builder resultBuilder = SqlExplainResult.Builder.newBuilder(); SqlExplainResult.Builder resultBuilder = SqlExplainResult.Builder.newBuilder();
try { try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment