abstractdog commented on code in PR #5613:
URL: https://github.com/apache/hive/pull/5613#discussion_r1926853360


##########
ql/src/java/org/apache/hadoop/hive/ql/DriverContext.java:
##########
@@ -247,4 +275,107 @@ public String getQueryErrorMessage() {
   public void setQueryErrorMessage(String queryErrorMessage) {
     this.queryErrorMessage = queryErrorMessage;
   }
+
+  public long getQueryStartTime() {
+    return getQueryInfo() != null ? getQueryInfo().getBeginTime() : 
getQueryDisplay().getQueryStartTime();
+  }
+
+  /**
+   * Resolves the query type from the SemanticAnalyzer and the query AST, 
which might look magic.
+   * Magic is needed because a query can fail due to semantic exceptions, and 
at that time, from syntax point of view,
+   * it's already clear what's the query type, even if the SemanticAnalyzer 
bailed out, typical problems:
+   * 1. general semantic exception
+   * 2. transaction manager validation (throwin exception)
+   * What a user expects here is something like "QUERY", "DDL", "DML", so this 
magic will do its best to tell.
+   * any kind of "analyze": STATS
+   * DML operations (INSERT, UPDATE, DELETE, MERGE): DML
+   * MAPRED: QUERY, DML (depending on QueryProperties achieved in compile time)
+   * FETCH: QUERY: a simple fetch task is a QUERY
+   * UNKNOWN: if we can't determine the type of the query:
+   * e.g. when ParseException happens, we won't do further magic,
+   * even if it's obvious by reading the sql statement that user wanted to run 
e.g. a select query
+   * @param sem the semantic analyzer which already analyzed the query
+   * @param tree the root ASTNode of the query
+   */
+  public void setQueryType(BaseSemanticAnalyzer sem, ASTNode tree) {
+    List<Task<? extends Serializable>> rootTasks = sem.getAllRootTasks();

Review Comment:
   moved this whole logic to BaseSemanticAnalyzer, as it's responsible already 
for filling QueryProperties with useful data, at the same time, I moved 
queryType and ddlType to QueryProperties too



-- 
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: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to