deniskuzZ commented on code in PR #5613: URL: https://github.com/apache/hive/pull/5613#discussion_r1939620152
########## ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java: ########## @@ -2094,4 +2117,79 @@ protected String getFullTableNameForSQL(ASTNode n) throws SemanticException { } } + public QB getQB(){ + return null; + } + + /** + * 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, as a simple fetch task is a QUERY + * empty string 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 tree the root ASTNode of the query + */ + public void setQueryType(ASTNode tree) { + List<Task<? extends Serializable>> rootTasks = getAllRootTasks(); + if (queryProperties == null) { + return; + } + queryProperties.setQueryType(queryProperties.isAnalyze() ? QueryType.STATS : Review Comment: 1. `setQueryType` shouldn't be public 2. AcidExportSemanticAnalyzer also extends RewriteSemanticAnalyzer, I think type should be OTHER in that case -- 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