Skip to content

Commit

Permalink
fix: fix can not get plan (#660)
Browse files Browse the repository at this point in the history
  • Loading branch information
yhilmare authored Oct 31, 2023
1 parent cfef0be commit 26c0f9c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@
- 'OB_MYSQL'
- 'OB_ORACLE'
- 'MYSQL'
propertiesJson: '{"${com.oceanbase.odc.builtin-resource.regulation.rule.sql-check.restrict-pk-datatypes.allowed-datatypes}":["int", "varchar2", "number", "float", "bigint"]}'
propertiesJson: '{"${com.oceanbase.odc.builtin-resource.regulation.rule.sql-check.restrict-pk-datatypes.allowed-datatypes}":["int", "varchar2", "varchar", "number", "float", "bigint"]}'
- enabled: 1
level: 0
environmentName: ${com.oceanbase.odc.builtin-resource.collaboration.environment.sit.name}
Expand Down Expand Up @@ -879,7 +879,7 @@
- 'OB_MYSQL'
- 'OB_ORACLE'
- 'MYSQL'
propertiesJson: '{"${com.oceanbase.odc.builtin-resource.regulation.rule.sql-check.restrict-pk-datatypes.allowed-datatypes}":["int", "varchar2", "number", "float", "bigint"]}'
propertiesJson: '{"${com.oceanbase.odc.builtin-resource.regulation.rule.sql-check.restrict-pk-datatypes.allowed-datatypes}":["int", "varchar2", "varchar", "number", "float", "bigint"]}'
- enabled: 1
level: 0
environmentName: ${com.oceanbase.odc.builtin-resource.collaboration.environment.dev.name}
Expand Down Expand Up @@ -1273,7 +1273,7 @@
- 'OB_MYSQL'
- 'OB_ORACLE'
- 'MYSQL'
propertiesJson: '{"${com.oceanbase.odc.builtin-resource.regulation.rule.sql-check.restrict-pk-datatypes.allowed-datatypes}":["int", "varchar2", "number", "float", "bigint"]}'
propertiesJson: '{"${com.oceanbase.odc.builtin-resource.regulation.rule.sql-check.restrict-pk-datatypes.allowed-datatypes}":["int", "varchar2", "varchar", "number", "float", "bigint"]}'
- enabled: 1
level: 0
environmentName: ${com.oceanbase.odc.builtin-resource.collaboration.environment.prod.name}
Expand Down Expand Up @@ -1658,7 +1658,7 @@
- 'OB_MYSQL'
- 'OB_ORACLE'
- 'MYSQL'
propertiesJson: '{"${com.oceanbase.odc.builtin-resource.regulation.rule.sql-check.restrict-pk-datatypes.allowed-datatypes}":["int", "varchar2", "number", "float", "bigint"]}'
propertiesJson: '{"${com.oceanbase.odc.builtin-resource.regulation.rule.sql-check.restrict-pk-datatypes.allowed-datatypes}":["int", "varchar2", "varchar", "number", "float", "bigint"]}'
- enabled: 1
level: 0
environmentName: ${com.oceanbase.odc.builtin-resource.collaboration.environment.default.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* @since ODC_release_4.2.0
*/
public class DiagnoseUtil {

public static PlanNode buildPlanTree(PlanNode planTree, PlanNode node) {
if (planTree == null) {
planTree = node;
Expand All @@ -52,15 +53,17 @@ public static String getNonexistKey(PlanNode node, String key) {
}

public static boolean recursiveBuild(PlanNode planTree, PlanNode node) {
PlanNode tempNode = planTree;
boolean flag = false;
if (tempNode.getDepth() + 1 == node.getDepth()) {
boolean flag;
if (planTree.getChildren() == null
|| planTree.getChildren().size() == 0
|| (planTree.getDepth() < node.getDepth()
&& planTree.getChildren().values().stream().allMatch(p -> p.getDepth() >= node.getDepth()))) {
String key = node.getOperator();
key = getNonexistKey(tempNode, key);
tempNode.getChildren().put(key, node);
key = getNonexistKey(planTree, key);
planTree.getChildren().put(key, node);
flag = true;
} else {
LinkedHashMap<String, PlanNode> children = tempNode.getChildren();
LinkedHashMap<String, PlanNode> children = planTree.getChildren();
Map.Entry<String, PlanNode> nodeEntry =
(Map.Entry<String, PlanNode>) children.entrySet().toArray()[children.size() - 1];
flag = recursiveBuild(nodeEntry.getValue(), node);
Expand Down

0 comments on commit 26c0f9c

Please sign in to comment.