add alias check

This commit is contained in:
lin
2022-08-04 14:50:58 +08:00
parent 412ccb7a08
commit 249ed82a72
@@ -143,12 +143,14 @@ public class HintPlanParse {
if (Strings.isNullOrEmpty(tableName)) {
throw new ConfigException("er Relation need like (a,b,c)");
}
nodeNameDuplicateCheck(tableName);
nodeMap.putIfAbsent(tableName, HintPlanNode.of(tableName));
hintPlanNodeMap.put(tableName, Type.ER);
}
nodeList.add(new Node(erData, Type.ER));
} else if (!StringUtil.isBlank(data)) {
nodeList.add(new Node(data));
nodeNameDuplicateCheck(data);
nodeMap.putIfAbsent(data, HintPlanNode.of(data));
hintPlanNodeMap.put(data, Type.OR);
}
@@ -192,6 +194,7 @@ public class HintPlanParse {
String lastTable = nodeName.toString();
if (!StringUtil.isBlank(lastTable)) {
nodeList.add(new Node(lastTable));
nodeNameDuplicateCheck(lastTable);
nodeMap.putIfAbsent(lastTable, HintPlanNode.of(lastTable));
hintPlanNodeMap.put(lastTable, Type.Other);
}
@@ -200,19 +203,27 @@ public class HintPlanParse {
@NotNull
private void addNode(String nodeName, List<Node> nodeList, boolean erRelation, Type type) throws ConfigException {
nodeNameDuplicateCheck(nodeName);
if (erRelation) {
throw new ConfigException("er Relation need like (a,b,c)");
}
if (nodeName.length() == 0) {
return;
}
nodeMap.putIfAbsent(nodeName, HintPlanNode.of(nodeName));
//table has dependencies will be added to the end
hintPlanNodeMap.put(nodeName, type);
nodeList.add(new Node(nodeName));
}
private void nodeNameDuplicateCheck(String nodeName) {
if (nodeMap.containsKey(nodeName)) {
throw new ConfigException("duplicate alias exist in the hint plan");
}
}
private void buildDependMap(Node root) {
LinkedList<Node> queue = new LinkedList<>();
queue.offer(root);
@@ -268,6 +279,11 @@ public class HintPlanParse {
return tableSet;
}
private void aliasRepeatCheck() {
}
private void setLeftNode(Node curNode, Node preNode) {
curNode.setLeftNode(preNode);
preNode.setParent(curNode);