kasakrisz commented on code in PR #6806:
URL: https://github.com/apache/hive/pull/6806#discussion_r4091538438
##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/SharedWorkOptimizer.java:
##########
@@ -2068,44 +2068,43 @@ private static Set<Operator<?>>
findAscendantOperators(SharedWorkOptimizerCache
return visited;
}
- private static Set<Operator<?>> findDescendantWorkOperators(ParseContext
pctx,
+ @VisibleForTesting
+ static Set<Operator<?>> findDescendantWorkOperators(ParseContext pctx,
SharedWorkOptimizerCache optimizerCache, Operator<?> start,
Set<Operator<?>> excludeOps) {
- // Find operators in work
- Set<Operator<?>> workOps = findWorkOperators(optimizerCache, start);
- // Gather output works operators
- Set<Operator<?>> result = new HashSet<Operator<?>>();
- Set<Operator<?>> set;
- while (!workOps.isEmpty()) {
- set = new HashSet<Operator<?>>();
- for (Operator<?> op : workOps) {
- if (excludeOps.contains(op)) {
- continue;
- }
- if (op instanceof ReduceSinkOperator) {
- if (op.getChildOperators() != null) {
- // All children of RS are descendants
- for (Operator<?> child : op.getChildOperators()) {
- set.addAll(findWorkOperators(optimizerCache, child));
- }
- }
- // Semijoin DPP work is considered a descendant because work needs
- // to finish for it to execute
- SemiJoinBranchInfo sjbi = pctx.getRsToSemiJoinBranchInfo().get(op);
- if (sjbi != null) {
- set.addAll(findWorkOperators(optimizerCache, sjbi.getTsOp()));
+
+ // Gather input operators
+ Set<Operator<?>> startWorkOperators = findWorkOperators(optimizerCache,
start);
+ Set<Operator<?>> visited = new HashSet<>();
+ Queue<Operator<?>> remaining = new LinkedList<>(startWorkOperators);
+ while (!remaining.isEmpty()) {
+ Operator<?> op = remaining.poll();
+ if (!visited.add(op) || excludeOps.contains(op)) {
+ continue;
+ }
+
+ if (op instanceof ReduceSinkOperator) {
+ if (op.getChildOperators() != null) {
+ // All children of RS are descendants
+ for (Operator<?> child : op.getChildOperators()) {
+ remaining.addAll(findWorkOperators(optimizerCache, child));
}
- } else if(op.getConf() instanceof DynamicPruningEventDesc) {
- // DPP work is considered a descendant because work needs
- // to finish for it to execute
- set.addAll(findWorkOperators(
- optimizerCache, ((DynamicPruningEventDesc)
op.getConf()).getTableScan()));
}
+ // Semijoin DPP work is considered a descendant because work needs
+ // to finish for it to execute
+ SemiJoinBranchInfo sjbi = pctx.getRsToSemiJoinBranchInfo().get(op);
+ if (sjbi != null) {
+ remaining.addAll(findWorkOperators(optimizerCache, sjbi.getTsOp()));
+ }
+ } else if (op.getConf() instanceof DynamicPruningEventDesc) {
+ // DPP work is considered a descendant because work needs
+ // to finish for it to execute
+ remaining.addAll(findWorkOperators(optimizerCache,
((DynamicPruningEventDesc) op.getConf()).getTableScan()));
}
- workOps = set;
Review Comment:
> SELECT * FROM t WHERE t.p = (SELECT max(p) FROM t);
Could you please share the context, DDL and sample data.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]