Dev Zhou
Dev Zhou

Reputation: 905

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

Upvotes: 0

Views: 318

Answers (1)

Ankit Agrahari
Ankit Agrahari

Reputation: 379

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';

Upvotes: 1

Related Questions