jihoonson commented on a change in pull request #11643:
URL: https://github.com/apache/druid/pull/11643#discussion_r701509642



##########
File path: sql/src/main/java/org/apache/druid/sql/SqlLifecycle.java
##########
@@ -372,15 +383,38 @@ public void after(boolean isDone, Throwable thrown)
   @VisibleForTesting
   public ValidationResult runAnalyzeResources(AuthenticationResult 
authenticationResult)
   {
-    synchronized (lock) {
-      return validate(authenticationResult);
+    return validate(authenticationResult);
+  }
+
+  public Set<Resource> getAuthorizedResources()
+  {
+    assert validationResult != null;
+    return validationResult.getResources();
+  }
+
+  /**
+   * Cancel all native queries associated to this lifecycle.
+   *
+   * This method is thread-safe.
+   */
+  public void cancel()
+  {
+    canceled = true;
+
+    final CopyOnWriteArrayList<String> nativeQueryIds = 
plannerContext.getNativeQueryIds();
+
+    for (String nativeQueryId : nativeQueryIds) {
+      log.debug("canceling native query [%s]", nativeQueryId);
+      queryScheduler.cancelQuery(nativeQueryId);
     }
   }
 
-  public RelDataType rowType()
+  public Optional<RelDataType> rowType()
   {
-    synchronized (lock) {
-      return plannerResult != null ? plannerResult.rowType() : 
prepareResult.getRowType();
+    if (canceled) {
+      return Optional.empty();

Review comment:
       I changed the behavior of transition being no-op when the query is 
cancelled to exploding immediately with `QueryInterruptedException`. This will 
let the query emit a request log and metrics even when the query is cancelled 
before its execution. I updated the PR description to include this change.




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