Commit c2f970d0 authored by gaopan's avatar gaopan

[Optimization][client] explainSqlRecord 方法优化

parent 16a4cdff
...@@ -250,9 +250,7 @@ public class CustomTableEnvironmentImpl extends TableEnvironmentImpl implements ...@@ -250,9 +250,7 @@ public class CustomTableEnvironmentImpl extends TableEnvironmentImpl implements
throw new TableException( throw new TableException(
"Unsupported SQL query! explainSql() only accepts a single SQL query."); "Unsupported SQL query! explainSql() only accepts a single SQL query.");
} }
List<Operation> operationlist = new ArrayList<>(operations); Operation operation = operations.get(0);
for (int i = 0; i < operationlist.size(); i++) {
Operation operation = operationlist.get(i);
if (operation instanceof ModifyOperation) { if (operation instanceof ModifyOperation) {
record.setType("Modify DML"); record.setType("Modify DML");
} else if (operation instanceof ExplainOperation) { } else if (operation instanceof ExplainOperation) {
...@@ -261,16 +259,13 @@ public class CustomTableEnvironmentImpl extends TableEnvironmentImpl implements ...@@ -261,16 +259,13 @@ public class CustomTableEnvironmentImpl extends TableEnvironmentImpl implements
record.setType("Query DML"); record.setType("Query DML");
} else { } else {
record.setExplain(operation.asSummaryString()); record.setExplain(operation.asSummaryString());
operationlist.remove(i);
record.setType("DDL"); record.setType("DDL");
i = i - 1;
}
} }
record.setExplainTrue(true); record.setExplainTrue(true);
if (operationlist.size() == 0) { if ("DDL".equals(record.getType())) {
return record; return record;
} }
record.setExplain(planner.explain(operationlist, extraDetails)); record.setExplain(planner.explain(operations, extraDetails));
return record; return record;
} }
......
...@@ -252,9 +252,7 @@ public class CustomTableEnvironmentImpl extends TableEnvironmentImpl implements ...@@ -252,9 +252,7 @@ public class CustomTableEnvironmentImpl extends TableEnvironmentImpl implements
throw new TableException( throw new TableException(
"Unsupported SQL query! explainSql() only accepts a single SQL query."); "Unsupported SQL query! explainSql() only accepts a single SQL query.");
} }
List<Operation> operationlist = new ArrayList<>(operations); Operation operation = operations.get(0);
for (int i = 0; i < operationlist.size(); i++) {
Operation operation = operationlist.get(i);
if (operation instanceof ModifyOperation) { if (operation instanceof ModifyOperation) {
record.setType("Modify DML"); record.setType("Modify DML");
} else if (operation instanceof ExplainOperation) { } else if (operation instanceof ExplainOperation) {
...@@ -263,16 +261,13 @@ public class CustomTableEnvironmentImpl extends TableEnvironmentImpl implements ...@@ -263,16 +261,13 @@ public class CustomTableEnvironmentImpl extends TableEnvironmentImpl implements
record.setType("Query DML"); record.setType("Query DML");
} else { } else {
record.setExplain(operation.asSummaryString()); record.setExplain(operation.asSummaryString());
operationlist.remove(i);
record.setType("DDL"); record.setType("DDL");
i = i - 1;
}
} }
record.setExplainTrue(true); record.setExplainTrue(true);
if (operationlist.size() == 0) { if ("DDL".equals(record.getType())) {
return record; return record;
} }
record.setExplain(planner.explain(operationlist, extraDetails)); record.setExplain(planner.explain(operations, extraDetails));
return record; return record;
} }
......
...@@ -253,9 +253,7 @@ public class CustomTableEnvironmentImpl extends TableEnvironmentImpl implements ...@@ -253,9 +253,7 @@ public class CustomTableEnvironmentImpl extends TableEnvironmentImpl implements
throw new TableException( throw new TableException(
"Unsupported SQL query! explainSql() only accepts a single SQL query."); "Unsupported SQL query! explainSql() only accepts a single SQL query.");
} }
List<Operation> operationlist = new ArrayList<>(operations); Operation operation = operations.get(0);
for (int i = 0; i < operationlist.size(); i++) {
Operation operation = operationlist.get(i);
if (operation instanceof ModifyOperation) { if (operation instanceof ModifyOperation) {
record.setType("Modify DML"); record.setType("Modify DML");
} else if (operation instanceof ExplainOperation) { } else if (operation instanceof ExplainOperation) {
...@@ -264,17 +262,14 @@ public class CustomTableEnvironmentImpl extends TableEnvironmentImpl implements ...@@ -264,17 +262,14 @@ public class CustomTableEnvironmentImpl extends TableEnvironmentImpl implements
record.setType("Query DML"); record.setType("Query DML");
} else { } else {
record.setExplain(operation.asSummaryString()); record.setExplain(operation.asSummaryString());
operationlist.remove(i);
record.setType("DDL"); record.setType("DDL");
i = i - 1;
}
} }
record.setExplainTrue(true); record.setExplainTrue(true);
if (operationlist.size() == 0) { if ("DDL".equals(record.getType())) {
//record.setExplain("DDL语句不进行解释。"); //record.setExplain("DDL语句不进行解释。");
return record; return record;
} }
record.setExplain(planner.explain(operationlist, extraDetails)); record.setExplain(planner.explain(operations, extraDetails));
return record; return record;
} }
......
...@@ -261,9 +261,8 @@ public class CustomTableEnvironmentImpl extends TableEnvironmentImpl implements ...@@ -261,9 +261,8 @@ public class CustomTableEnvironmentImpl extends TableEnvironmentImpl implements
throw new TableException( throw new TableException(
"Unsupported SQL query! explainSql() only accepts a single SQL query."); "Unsupported SQL query! explainSql() only accepts a single SQL query.");
} }
List<Operation> operationlist = new ArrayList<>(operations);
for (int i = 0; i < operationlist.size(); i++) { Operation operation = operations.get(0);
Operation operation = operationlist.get(i);
if (operation instanceof ModifyOperation) { if (operation instanceof ModifyOperation) {
record.setType("Modify DML"); record.setType("Modify DML");
} else if (operation instanceof ExplainOperation) { } else if (operation instanceof ExplainOperation) {
...@@ -272,17 +271,14 @@ public class CustomTableEnvironmentImpl extends TableEnvironmentImpl implements ...@@ -272,17 +271,14 @@ public class CustomTableEnvironmentImpl extends TableEnvironmentImpl implements
record.setType("Query DML"); record.setType("Query DML");
} else { } else {
record.setExplain(operation.asSummaryString()); record.setExplain(operation.asSummaryString());
operationlist.remove(i);
record.setType("DDL"); record.setType("DDL");
i = i - 1;
}
} }
record.setExplainTrue(true); record.setExplainTrue(true);
if (operationlist.size() == 0) { if ("DDL".equals(record.getType())) {
//record.setExplain("DDL语句不进行解释。"); //record.setExplain("DDL语句不进行解释。");
return record; return record;
} }
record.setExplain(planner.explain(operationlist, extraDetails)); record.setExplain(planner.explain(operations, extraDetails));
return record; return record;
} }
......
...@@ -214,9 +214,7 @@ public class CustomTableEnvironmentImpl extends AbstractStreamTableEnvironmentIm ...@@ -214,9 +214,7 @@ public class CustomTableEnvironmentImpl extends AbstractStreamTableEnvironmentIm
throw new TableException( throw new TableException(
"Unsupported SQL query! explainSql() only accepts a single SQL query."); "Unsupported SQL query! explainSql() only accepts a single SQL query.");
} }
List<Operation> operationlist = new ArrayList<>(operations); Operation operation = operations.get(0);
for (int i = 0; i < operationlist.size(); i++) {
Operation operation = operationlist.get(i);
if (operation instanceof ModifyOperation) { if (operation instanceof ModifyOperation) {
record.setType("Modify DML"); record.setType("Modify DML");
} else if (operation instanceof ExplainOperation) { } else if (operation instanceof ExplainOperation) {
...@@ -225,17 +223,14 @@ public class CustomTableEnvironmentImpl extends AbstractStreamTableEnvironmentIm ...@@ -225,17 +223,14 @@ public class CustomTableEnvironmentImpl extends AbstractStreamTableEnvironmentIm
record.setType("Query DML"); record.setType("Query DML");
} else { } else {
record.setExplain(operation.asSummaryString()); record.setExplain(operation.asSummaryString());
operationlist.remove(i);
record.setType("DDL"); record.setType("DDL");
i = i - 1;
}
} }
record.setExplainTrue(true); record.setExplainTrue(true);
if (operationlist.size() == 0) { if ("DDL".equals(record.getType())) {
//record.setExplain("DDL语句不进行解释。"); //record.setExplain("DDL语句不进行解释。");
return record; return record;
} }
record.setExplain(planner.explain(operationlist, extraDetails)); record.setExplain(planner.explain(operations, extraDetails));
return record; return record;
} }
......
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