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


##########
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:
   I was thinking about enums, but I was afraid that at other points in hive, 
this classification of queries is not accepted due to some reason, making it 
query history specific, but yeah, finally this ended up in DriverContext :) 
ready to move it around SemanticAnalyzer and unify the values as enums, which 
would solve the other question too (whether getQueryType fits here)



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