Sparksql查询hive分区表出现
java.io.IOException: Not a file: hdfs://ns/data/hjpt/itf/14thplatform/qchat/month/active_user
错误。
今天在sparksql中查询hive的分区表的时候,
select * from itf_qchat_active_user_m where month_id = ‘201701’ limit 10;
结果出现错误,
17/06/15 14:52:50 ERROR SparkSQLDriver: Failed in [select * from itf_qchat_active_user_m limit 10]
java.io.IOException: Not a file: hdfs://ns/data/hjpt/itf/14thplatform/qchat/month/active_user
但是hadoop 中的确存在201701这个文件夹,通过hadoop 命令可以认证。
同时,查询其他分区表没有错误,而且hive查询没有问题
那么可以确定,问题出现在这个表中。后来,让创建这个表的工作人员查看,原来在这个表还有一个201702的分区,这个分区是空的,没有对应的hdfs目录,从而导致201701的分区查询错误。后来,删除这个分区
alter table itf_qchat_active_user_m drop partition (month_id=’201702’)后,查询正常。