在蜂巢的外部表中创建分区 [英] creating partition in external table in hive

查看:129
本文介绍了在蜂巢的外部表中创建分区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功在蜂巢的内部表中创建并添加了动态分区.即使用以下步骤:

I have successfully created and added Dynamic partitions in an Internal table in hive. i.e. by using following steps:

1创建了一个源表

2将数据从本地加载到源表

2-loaded data from local into source table

3-创建了另一个带有分区的表-partition_table

3- created another table with partitions - partition_table

4-将数据从源表插入此表,从而动态创建所有分区

4- inserted the data to this table from source table resulting in creation of all the partitions dynamically

我的问题是,如何在外部表中执行此操作?我读了很多关于此的文章,但是我很困惑,我是否必须指定到现有分区的路径才能为外部表创建分区?

My question is, how to perform this in external table? I read so many articles on this, but i am confused , that do I have to specify path to the already existing partitions for creating partitions for external table??

示例: 步骤1:

create external table1 ( name string, age int, height int)
location 'path/to/dataFile/in/HDFS';

第2步:

alter table table1 add partition(age) 
location 'path/to/already/existing/partition'

我不确定如何在外部表中进行分区.有人可以提供有关它的逐步说明吗?

I am not sure how to proceed with partitioning in external tables. Can somebody please help by giving step by step description of the same?.

提前谢谢!

推荐答案

1.设置以下属性

set hive.exec.dynamic.partition=true

set hive.exec.dynamic.partition.mode=nonstrict

2.创建外部分区表

create external table1 ( name string, age int, height int) location 'path/to/dataFile/in/HDFS';

create external table1 ( name string, age int, height int) location 'path/to/dataFile/in/HDFS';

3.将数据从源表插入分区表.

基本上,过程是相同的.只是您创建了外部分区表并提供了HDFS指向该表的路径,它将在该路径下创建和存储分区.

Basically , the process is same. its just that you create external partitioned table and provide HDFS path to table under which it will create and store partition.

希望这会有所帮助.

这篇关于在蜂巢的外部表中创建分区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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