JackieTien97 commented on code in PR #16623:
URL: https://github.com/apache/iotdb/pull/16623#discussion_r2444603407
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/distribute/TableDistributedPlanGenerator.java:
##########
@@ -1054,8 +1056,70 @@ public List<PlanNode> visitAggregation(AggregationNode
node, PlanContext context
// child
}
+ // push down aggregation if the child of aggregation node only has the
union Node
if (childrenNodes.size() == 1) {
node.setChild(childrenNodes.get(0));
+
+ if (childrenNodes.get(0) instanceof UnionNode
+ && node.getAggregations().values().stream()
+ .noneMatch(aggregation -> aggregation.isDistinct() ||
aggregation.hasMask())) {
+ UnionNode unionNode = (UnionNode) childrenNodes.get(0);
+ List<PlanNode> children = unionNode.getChildren();
+
+ // 1. add the project Node above the children of the union node
+ List<PlanNode> newProjectNodes = new ArrayList<>();
+ Set<Map.Entry<Symbol, Collection<Symbol>>> outputToInput =
+ unionNode.getSymbolMapping().asMap().entrySet();
+
+ List<Symbol> unionOutputSymbols = unionNode.getOutputSymbols();
+ for (PlanNode planNode : children) {
+ List<Symbol> childOutputSymbols = planNode.getOutputSymbols();
+ Assignments.Builder assignmentsBuilder = Assignments.builder();
+ for (int i = 0; i < unionOutputSymbols.size(); i++) {
+ Symbol unionSymbol = unionOutputSymbols.get(i);
+ Symbol childSymbol = childOutputSymbols.get(i);
+ assignmentsBuilder.put(unionSymbol,
childSymbol.toSymbolReference());
Review Comment:
I'm not sure whether the output sequence in UnionNode is same as output
sequence in each child.
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/distribute/TableDistributedPlanGenerator.java:
##########
@@ -1054,8 +1056,70 @@ public List<PlanNode> visitAggregation(AggregationNode
node, PlanContext context
// child
}
+ // push down aggregation if the child of aggregation node only has the
union Node
if (childrenNodes.size() == 1) {
node.setChild(childrenNodes.get(0));
+
+ if (childrenNodes.get(0) instanceof UnionNode
+ && node.getAggregations().values().stream()
+ .noneMatch(aggregation -> aggregation.isDistinct() ||
aggregation.hasMask())) {
+ UnionNode unionNode = (UnionNode) childrenNodes.get(0);
+ List<PlanNode> children = unionNode.getChildren();
+
+ // 1. add the project Node above the children of the union node
+ List<PlanNode> newProjectNodes = new ArrayList<>();
+ Set<Map.Entry<Symbol, Collection<Symbol>>> outputToInput =
Review Comment:
not used.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]