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

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

问题描述

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

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.设置下面的属性

设置 hive.exec.dynamic.partition=true

设置 hive.exec.dynamic.partition.mode=nonstrict

<强>2.创建外部分区表

create external table1 (name string, age int, height int)位置'路径/到/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.

希望这会有所帮助.

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

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