paul-rogers commented on a change in pull request #1975: DRILL-7576: Fail fast 
for operator errors
URL: https://github.com/apache/drill/pull/1975#discussion_r377985719
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/BaseRootExec.java
 ##########
 @@ -184,4 +179,38 @@ public void close() throws Exception {
       }
     }
   }
+
+  /**
+   * Given a list of operators and a stack trace, walks the stack trace and
+   * the operator list to find the leaf-most operator, which is the one
+   * that was active when the exception was thrown. Handle the cases in
+   * which no operator was active, each operator had multiple methods on
+   * the stack, or the exception was thrown in some class called by
+   * the operator.
+   * <p>
+   * Not all operators leave a mark in the trace. In particular if a the
+   * call stack is only through base-class methods, then we have no way to
+   * know the actual class during the call. This is OK because the leaf
+   * methods are just pass-through operations, they are unlikely to fail.
+   *
+   * @param <T> the type of the operator. Parameterized to allow easier
+   * testing
+   * @param dag the list of operators from root-most to leaf-most
+   * @param e the exception thrown somewhere in the operator tree
+   * @return the leaf-most operator, if any
+   */
+  public static <T> T findLeaf(List<T> dag, Throwable e) {
+    StackTraceElement[] trace = e.getStackTrace();
 
 Review comment:
   Here order is important. Yes, we could pre-process the list to remove all 
non-Drill methods. Not sure the time savings is worth the code complexity given 
that this code occurs only in error conditions, and only when enabled.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to