为什么hive在使用分区时不能从hdfs中选择数据?

0h4hbjxa  于 2021-06-04  发布在  Flume
关注(0)|答案(1)|浏览(263)

我使用flume将数据写入hdfs,就像路径一样 /hive/logs/dt=20151002 。然后,我使用配置单元选择数据,但响应的计数始终为0。
这是我的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' 这是我的选择sql, select count(*) from test

b4qexyjb

b4qexyjb1#

似乎您没有在配置单元元存储中注册分区。虽然分区存在于hdfs路径中,但如果它没有在元存储中注册,hive就不会知道它。要注册它,您可以执行以下操作:
alter table test add partition(dt='20151002')location'/hive/logs/dt=20151002';

相关问题