A small drop table problem encountered previously. By default, anyone can have the permission to use drop dB. Table.
This is a bug,
bugid:https://issues.apache.org/jira/browse/HIVE-2817
Solution:
You can set
set hive.exec.drop.ignorenonexistent=false(Do not report an error if DROP TABLE/VIEW specifies a non-existent table/view,
The default value is true,
DROPIGNORESNONEXISTENT("hive.exec.drop.ignorenonexistent", true)
.
Workaround:set hive.exec.drop.ignorenonexistent=false.Before that,we need to check all the "drop" sqls and change to drop if exists.we need to remove all "drop table db.table" syntax to "use db; drop table if exists table;"
However, if hive.exe C. Drop. ignorenonexistent = false is set, if the table xxx does not exist, an error is returned when you drop table xxx.
hive> set hive.exec.drop.ignorenonexistent=false;hive> drop table tt; FAILED: SemanticException [Error 10001]: Table not found tthive> set hive.exec.drop.ignorenonexistent=true;hive> drop table tt; OKTime taken: 0.055 seconds
In addition, the drop db.tablesyntax also reports an error. If you set hive.exe C. Drop. ignorenonexistent to true, no error is reported.
hive> set hive.exec.drop.ignorenonexistent=true;hive> drop table cdnlog.ttt;FAILED: SemanticException [Error 10001]: Table not found cdnlog.ttthive> use cdnlog;drop table ttt;OKTime taken: 0.042 secondsOKset hive.exec.drop.ignorenonexistent=true;hive> drop table cdnlog.ttt;OK
Because you can change the price of etl SQL, you can set hive.exe C. Drop. ignorenonexistent to true. In addition, you need to fix this bug.
Drop table is a DDL operation, and the path of the related analyzer classes is:
ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
The corresponding method is analyzedroptable:
@@ -721,13 +716,30 @@ private void analyzeDropTable(ASTNode ast, boolean expectView) throws SemanticException { String tableName = getUnescapedName((ASTNode) ast.getChild(0)); boolean ifExists = (ast.getFirstChildWithType(HiveParser.TOK_IFEXISTS) != null); // we want to signal an error if the table/view doesn‘t exist and we‘re // configured not to fail silently boolean throwException = !ifExists && !HiveConf.getBoolVar(conf, ConfVars.DROPIGNORESNONEXISTENT); try {- Table tab = db.getTable(db.getCurrentDatabase(), tableName, throwException);+ // to fix the drop table bug+ String tableName2 = "";+ if (tableName.contains(".")) {+ try {+ tableName2 = tableName.split("\\.")[1];+ } catch (Exception e) {+ // do nothing if tableName can‘t be splitted+ tableName2 = tableName;+ }+ } else {+ tableName2 = tableName;+ }+ Table tab = db.getTable(db.getCurrentDatabase(), tableName2, throwException);++ // Table tab = db.getTable(db.getCurrentDatabase(), tableName, throwException);+ if (tab != null) { inputs.add(new ReadEntity(tab)); outputs.add(new WriteEntity(tab));
This article from the "Food light blog" blog, please be sure to keep this source http://caiguangguang.blog.51cto.com/1652935/1558885
Hive can drop bugs in all tables