This is an automated email from the ASF dual-hosted git repository.
caogaofei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 68eb91af45b Support print plan when assert fails in PlanMatchPattern
68eb91af45b is described below
commit 68eb91af45bc2940bc0edf6cc4dc76f8ff3a6dfa
Author: Weihao Li <[email protected]>
AuthorDate: Fri Sep 20 15:41:47 2024 +0800
Support print plan when assert fails in PlanMatchPattern
---
.../plan/planner/plan/node/PlanGraphPrinter.java | 28 +++++++++++++++-------
.../relational/planner/assertions/PlanAssert.java | 3 ++-
2 files changed, 22 insertions(+), 9 deletions(-)
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/PlanGraphPrinter.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/PlanGraphPrinter.java
index 959a5ebe544..b78cd78940a 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/PlanGraphPrinter.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/PlanGraphPrinter.java
@@ -619,7 +619,12 @@ public class PlanGraphPrinter extends
PlanVisitor<List<String>, PlanGraphPrinter
boxValue.add(String.format("PushDownOffset: %s",
node.getPushDownOffset()));
boxValue.add(String.format("PushDownLimit: %s", node.getPushDownLimit()));
boxValue.add(String.format("PushDownLimitToEachDevice: %s",
node.isPushLimitToEachDevice()));
- boxValue.add(String.format("RegionId: %s",
node.getRegionReplicaSet().getRegionId().getId()));
+ boxValue.add(
+ String.format(
+ "RegionId: %s",
+ node.getRegionReplicaSet() == null
+ ? ""
+ : node.getRegionReplicaSet().getRegionId().getId()));
return render(node, boxValue, context);
}
@@ -630,9 +635,6 @@ public class PlanGraphPrinter extends
PlanVisitor<List<String>, PlanGraphPrinter
List<String> boxValue = new ArrayList<>();
boxValue.add(String.format("Aggregation-%s",
node.getPlanNodeId().getId()));
boxValue.add(String.format("OutputSymbols: %s", node.getOutputSymbols()));
- if (node.isStreamable()) {
- boxValue.add("Streamable: true");
- }
int i = 0;
for
(org.apache.iotdb.db.queryengine.plan.relational.planner.node.AggregationNode.Aggregation
aggregation : node.getAggregations().values()) {
@@ -640,6 +642,10 @@ public class PlanGraphPrinter extends
PlanVisitor<List<String>, PlanGraphPrinter
String.format("Aggregator-%d: %s", i++,
aggregation.getResolvedFunction().toString()));
}
boxValue.add(String.format("GroupingKeys: %s", node.getGroupingKeys()));
+ if (node.isStreamable()) {
+ boxValue.add("Streamable: true");
+ boxValue.add(String.format("PreGroupedSymbols: %s",
node.getPreGroupedSymbols()));
+ }
boxValue.add(String.format("Step: %s", node.getStep()));
return render(node, boxValue, context);
}
@@ -652,9 +658,6 @@ public class PlanGraphPrinter extends
PlanVisitor<List<String>, PlanGraphPrinter
boxValue.add(String.format("AggregationTableScan-%s",
node.getPlanNodeId().getId()));
boxValue.add(String.format("QualifiedTableName: %s",
node.getQualifiedObjectName().toString()));
boxValue.add(String.format("OutputSymbols: %s", node.getOutputSymbols()));
- if (node.isStreamable()) {
- boxValue.add("Streamable: true");
- }
int i = 0;
for
(org.apache.iotdb.db.queryengine.plan.relational.planner.node.AggregationNode.Aggregation
aggregation : node.getAggregations().values()) {
@@ -662,6 +665,10 @@ public class PlanGraphPrinter extends
PlanVisitor<List<String>, PlanGraphPrinter
String.format("Aggregator-%d: %s", i++,
aggregation.getResolvedFunction().toString()));
}
boxValue.add(String.format("GroupingKeys: %s", node.getGroupingKeys()));
+ if (node.isStreamable()) {
+ boxValue.add("Streamable: true");
+ boxValue.add(String.format("PreGroupedSymbols: %s",
node.getPreGroupedSymbols()));
+ }
boxValue.add(String.format("Step: %s", node.getStep()));
if (node.getProjection() != null) {
@@ -677,7 +684,12 @@ public class PlanGraphPrinter extends
PlanVisitor<List<String>, PlanGraphPrinter
boxValue.add(String.format("PushDownOffset: %s",
node.getPushDownOffset()));
boxValue.add(String.format("PushDownLimit: %s", node.getPushDownLimit()));
boxValue.add(String.format("PushDownLimitToEachDevice: %s",
node.isPushLimitToEachDevice()));
- boxValue.add(String.format("RegionId: %s",
node.getRegionReplicaSet().getRegionId().getId()));
+ boxValue.add(
+ String.format(
+ "RegionId: %s",
+ node.getRegionReplicaSet() == null
+ ? ""
+ : node.getRegionReplicaSet().getRegionId().getId()));
return render(node, boxValue, context);
}
diff --git
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/planner/assertions/PlanAssert.java
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/planner/assertions/PlanAssert.java
index c3422f78760..bdb25b26d80 100644
---
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/planner/assertions/PlanAssert.java
+++
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/planner/assertions/PlanAssert.java
@@ -17,6 +17,7 @@ import org.apache.iotdb.commons.conf.IoTDBConstant;
import org.apache.iotdb.db.protocol.session.IClientSession;
import org.apache.iotdb.db.queryengine.common.SessionInfo;
import org.apache.iotdb.db.queryengine.plan.planner.plan.LogicalQueryPlan;
+import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanGraphPrinter;
import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanNode;
import org.apache.iotdb.db.queryengine.plan.relational.analyzer.TestMatadata;
import org.apache.iotdb.db.queryengine.plan.relational.metadata.Metadata;
@@ -71,7 +72,7 @@ public final class PlanAssert {
throw new AssertionError(
format(
"Plan does not match, expected [\n\n%s\n] but found
[\n\n%s\n], matches:[%s]",
- pattern, actual, matches));
+ pattern, String.join("\n", actual.accept(new
PlanGraphPrinter(), null)), matches));
}
// TODO support print plan tree
PlanNode resolvedPlan = resolveGroupReferences(actual, lookup);