hive Error SemanticException Unable to fetch table

1,025 阅读1分钟

一系列奇怪的操作后(建表中断、删表插入等。。)

hive表想删除报错

select * from tablename limit 2;
Error: Error while compiling statement: FAILED: SemanticException Unable to fetch table tablename. null (state=42000,code=40000)
drop table tablename;

 经过百度,找到一个解决问题的办法

操作hive对应的Mysql

  1. select DB_ID from DBS where NAME='your-database-name'\
  2. select tbl_id from TBLS where TBL_NAME='your-table-name' and DB_ID=<id from step 1>;\
  3. delete from PARTITION_KEY_VALS WHERE PART_ID in (select PART_ID from PARTITIONS where TBL_ID=<id from step 2>);\
  4. delete from PARTITION_PARAMS WHERE PART_ID in (select PART_ID from PARTITIONS where TBL_ID=<id from step 2>); \
  5. delete from PARTITIONS where TBL_ID=<id from step 2>; \
  6. delete from TBL_COL_PRIVS where TBL_ID=<id from step 2>;\
  7. delete from TBL_PRIVS where TBL_ID=<id from step 2>; \
  8. delete from TBLS where TBL_ID=<id from step 2>; \
  9. COMMIT; 

问题解决