蜂巢:为现有文件夹结构添加分区 [英] Hive: Add partitions for existing folder structure

查看:119
本文介绍了蜂巢:为现有文件夹结构添加分区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在HDFS中有一个文件夹结构,如下所示.但是,即使将文件夹结构设置为好像表具有分区一样,实际上也没有使用ALTER TABLE ADD PARTITION命令在表上创建任何分区.

I have a folder structure in HDFS like below. However, no partitions were actually created on the table using the ALTER TABLE ADD PARTITION commands, even though the folder structure was setup as if the table had partitions.

如何自动将所有分区添加到Hive表中? (配置单元1.0,外部表)

How can I automatically add all the partitions to the Hive table? (Hive 1.0, external table)

/user/frank/clicks.db
  /date=20190401
    /file0004.csv
  /date=20190402
    /file0009.csv
  /date=20190501
    /file0000.csv
    /file0001.csv
...etc

推荐答案

使用msck修复表命令:

Use msck repair table command:

MSCK [REPAIR] TABLE tablename;

ALTER TABLE tablename RECOVER PARTITIONS;

如果您正在EMR上运行Hive.

if you are running Hive on EMR.

在此处阅读有关这两个命令的更多详细信息:恢复分区

Read more details about both commands here: RECOVER PARTITIONS

这篇关于蜂巢:为现有文件夹结构添加分区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆