Skip to content

Commit

Permalink
handling misc query types
Browse files Browse the repository at this point in the history
  • Loading branch information
abstractdog committed Feb 5, 2025
1 parent 865d250 commit 0d10e1b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Map;

import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
import org.apache.hadoop.hive.ql.QueryProperties;
import org.apache.hadoop.hive.ql.QueryState;
import org.apache.hadoop.hive.ql.ddl.DDLWork;
import org.apache.hadoop.hive.ql.ddl.DDLSemanticAnalyzerFactory.DDLType;
Expand Down Expand Up @@ -103,4 +104,9 @@ private boolean isMsckAddPartition(int type) {
private boolean isMsckDropPartition(int type) {
return type == HiveParser.KW_SYNC || type == HiveParser.KW_DROP;
}

@Override
public void setQueryType(ASTNode tree) {
queryProperties.setQueryType(QueryProperties.QueryType.OTHER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.hadoop.hive.metastore.api.CompactionType;
import org.apache.hadoop.hive.metastore.api.FieldSchema;
import org.apache.hadoop.hive.ql.ErrorMsg;
import org.apache.hadoop.hive.ql.QueryProperties;
import org.apache.hadoop.hive.ql.QueryState;
import org.apache.hadoop.hive.ql.ddl.DDLWork;
import org.apache.hadoop.hive.ql.ddl.DDLSemanticAnalyzerFactory.DDLType;
Expand Down Expand Up @@ -129,4 +130,10 @@ protected void analyzeCommand(TableName tableName, Map<String, String> partition
public boolean isRequiresOpenTransaction() {
return false; // doesn't need an open txn
}

@Override
public void setQueryType(ASTNode tree) {
// ALTER TABLE COMPACT doesn't change the table's metadata or the data itself
queryProperties.setQueryType(QueryProperties.QueryType.OTHER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,15 @@ public void testQueryTypes() throws Exception {
// DDL: materialized view
checkQueryType("CREATE MATERIALIZED VIEW mv1 AS SELECT * FROM table_acid", QueryType.DDL);
checkQueryType("DROP MATERIALIZED VIEW IF EXISTS mv1", QueryType.DDL);
checkQueryType("ALTER MATERIALIZED VIEW mview_acid ENABLE REWRITE", QueryType.DDL);
checkQueryType("ALTER MATERIALIZED VIEW mview_acid REBUILD", QueryType.DDL);


// OTHER
// EXPLAIN is a utility, cannot classified as any of the categories above
checkQueryType("EXPLAIN SELECT key FROM table1", QueryType.OTHER);
checkQueryType("MSCK REPAIR TABLE table_part", QueryType.OTHER);
checkQueryType("ALTER TABLE table_acid COMPACT 'major'", QueryType.OTHER);
}

private void checkQueryType(String query, QueryProperties.QueryType expectedQueryType) throws Exception {
Expand Down

0 comments on commit 0d10e1b

Please sign in to comment.