删除 hdfs 路径后,如何在 Hive 中删除外部 table?

How to delete an external table in Hive when the hdfs path has been deleted?

我删除了我的 HDFS 路径 /user/abc,一些 Hive 表存储在 /user/abc/data/abc.db 中,使用 rm -R 命令。

尽管使用 Hive SQL 正确删除了我的常规表,但我的 外部 表没有删除,并出现以下错误:

[Code: 1, SQL State: 08S01]  Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:Failed to load storage handler:  Error in loading storage handler.org.apache.phoenix.hive.PhoenixStorageHandler)

如何安全删除表?

我尝试使用:

 delete from TBL_COL_PRIVS where TBL_ID=[myexternaltableID];
 delete from TBL_PRIVS where TBL_ID=[myexternaltableID];
 delete from TBLS where TBL_ID=[myexternaltableID];

但它没有工作,出现以下错误消息:

[Code: 10297, SQL State: 42000]  Error while compiling statement: FAILED: SemanticException [Error 10297]: Attempt to do update or delete on table sys.TBLS that is not transactional

谢谢,

注意:我知道应该使用 HiveQL 更安全地删除模式,但在这种特殊情况下,这不是这样做的。

解决方案是使用

Hive Metastore (PostgreSQL) 中删除表
delete from "TABLE_PARAMS" where "TBL_ID"='[myexternaltableID]';
delete from "TBL_COL_PRIVS" where "TBL_ID"='[myexternaltableID]';
delete from "TBL_PRIVS" where "TBL_ID"='[myexternaltableID]';
delete from "TBLS" where "TBL_ID"='[myexternaltableID]';

注意:顺序很重要。