在蜂巢的外部表中创建分区
我已经成功在蜂巢的内部表中创建并添加了动态分区.即使用以下步骤:
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.
希望这会有所帮助.