pvary commented on a change in pull request #2865:
URL: https://github.com/apache/hive/pull/2865#discussion_r768591706



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/reexec/ReExecDriver.java
##########
@@ -167,20 +201,25 @@ public CommandProcessorResponse run() throws 
CommandProcessorException {
       }
 
       PlanMapper oldPlanMapper = coreDriver.getPlanMapper();
-      afterExecute(oldPlanMapper, cpr != null);
+      final boolean success = cpr != null;
+      plugins.forEach(p -> p.afterExecute(oldPlanMapper, success));
+
+      // If the execution was successful return the result
+      if (success) {
+        return cpr;
+      }
 
       boolean shouldReExecute = explainReOptimization && executionIndex==1;
-      shouldReExecute |= cpr == null && shouldReExecute();
+      shouldReExecute |= plugins.stream().anyMatch(p -> 
p.shouldReExecute(executionIndex));
 
-      if (executionIndex >= maxExecutuions || !shouldReExecute) {
-        if (cpr != null) {
-          return cpr;
-        } else {
-          throw cpe;
-        }
+      if (executionIndex >= maxExecutions || !shouldReExecute) {
+        // If we do not have to reexecute, return the last error
+        throw cpe;
       }
+
       LOG.info("Preparing to re-execute query");
-      prepareToReExecute();
+      plugins.forEach(IReExecutionPlugin::prepareToReExecute);

Review comment:
       As discussed, most of them was just a loop, so I would keep this instead 
of having 6 methods for loops




-- 
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]

Reply via email to