简体   繁体   English

将分区的数据插入分区的配置单元表

[英]Insert partitioned data into partitioned hive table

I have stored the data in hdfs using Pig Multistorage with the column id. 我已经使用带有列ID的Pig Multistorage将数据存储在hdfs中。

So data stored as 所以数据存储为

/output/1/part-0000
/output/2/
/output/3/

Now I have created a partitioned table in hive and I want to load the data from /output folder into this partitioned table. 现在,我在配置单元中创建了一个分区表,我想将数据从/ output文件夹加载到该分区表中。 Is there any way to achieve this? 有什么办法可以做到这一点?

First you create a temp hive table where you load all the data from pig output. 首先,您创建一个临时配置单元表,从其中加载清管器输出中的所有数据。
Then You load to your actual partitioned hive table from temp table. 然后,您将从temp表加载到实际的分区配置单元表。
Something like below: 如下所示:

FROM emp_external temp INSERT OVERWRITE TABLE emp_partition PARTITION(country) SELECT temp.id,temp.name,temp.dept,temp.sal,temp.country;   

Else you can explore Hcatlog for this case. 另外,您可以在这种情况下浏览Hcatlog。

not sure if you are looking to insert the data in the outputfolder (created from pig) to an existing table or loading the data in the output folder in to a new hive partitioned table. 不知道您是否要在将输出文件夹(由Pig创建)中的数据插入到现有表中,或将输出文件夹中的数据加载到新的配置单元分区表中。

If you want to load the data in to new hive table, you can create a new partitioned table pointing to the output folder 如果要将数据加载到新的配置单元表中,则可以创建一个指向输出文件夹的新分区表

If you are looking to load the data into an existing hive table, then you can either create a temp table as @Aman mentioed and do a insert in to the destination table 如果希望将数据加载到现有的配置单元表中,则可以按照@Aman的指导创建一个临时表,并在目标表中进行插入

or 要么

You can just move/copy the files in the hdfs from output/ to hive table location. 您可以将hdfs中的文件从output /移动/复制到hive表位置。

Hope this helps 希望这可以帮助

Assign a Hive schema to pig output location with partitioned columns (Alter table Add Partition) as column id. 使用分区列(Alter表“添加分区”)作为列ID将Hive架构分配给Pig输出位置。 Now both are hive tables and you can use where clause over partitioned column to move over the data. 现在这两个都是配置单元表,您可以在分区列上使用where子句来移动数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM