当前位置: 动力学知识库 > 问答 > 编程问答 >

why hive can‘t select data from hdfs when use partition?

问题描述:

I use flume to write data to hdfs,path like /hive/logs/dt=20151002.Then,i use hive to select data,but the count of response is always 0.

Here is my create table sql,CREATE EXTERNAL TABLE IF NOT EXISTS test (id STRING) partitioned by (dt string) ROW FORMAT DELIMITED fields terminated by '\t' lines terminated by '\n' STORED AS TEXTFILE LOCATION '/hive/logs'

Here is my select sql,select count(*) from test

网友答案:

It seems that you are not registering partition in hive meta-store. Although partition is present in hdfs path,Hive won't know it if its not registered in meta store. To register it you can do the following:

ALTER TABLE test ADD PARTITION (dt='20151002') location '/hive/logs/dt=20151002';

分享给朋友:
您可能感兴趣的文章:
随机阅读: