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

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

问题描述

我在 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 表中?(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

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

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