Commit bea56361 authored by wenmo's avatar wenmo

assert

parent 0d660379
......@@ -168,7 +168,7 @@ public class CustomTableEnvironmentImpl extends TableEnvironmentImpl {
ObjectNode jsonNode = jsonGenerator.getJSONNode();
return jsonNode;
}else{
throw new TableException("Unsupported SQL query! explainSql() need a single SQL to query.");
throw new TableException("Unsupported SQL query! ExecEnv need a ExecutorBase.");
}
}
}
......
......@@ -38,4 +38,10 @@ public class Asserts {
}
}
public static void checkNotNull(Object object,String msg) {
if (isNull(object)) {
throw new JobException(msg);
}
}
}
package com.dlink.explainer.trans;
import com.dlink.assertion.Asserts;
import com.dlink.exception.SqlException;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode;
......@@ -23,7 +24,7 @@ public class TransGenerator {
this.plan = plan;
}
public static Trans get(String pact) {
public static Trans getTrans(String pact) {
switch (pact) {
case OperatorTrans.TRANS_TYPE:
return new OperatorTrans();
......@@ -42,10 +43,8 @@ public class TransGenerator {
Map<Integer, Trans> nodemap = new HashMap<>();
for (JsonNode node : nodes) {
String pact = node.get("pact").asText();
Trans trans = get(pact);
if (trans==null) {
throw new SqlException("该转换无法被解析,原文如下:" + pact);
}
Trans trans = getTrans(pact);
Asserts.checkNotNull(trans,"该转换无法被解析,原文如下:" + pact);
trans.build(node);
nodemap.put(trans.getId(), trans);
}
......
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