如何将新数据追加到现有的配置单元表 [英] How to Append new data to already existing hive table

查看:142
本文介绍了如何将新数据追加到现有的配置单元表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将记录追加到现有分区的Hive表中? 例如,我现有一个名为"ip_country"的外部表,数据集为testdata1.如果数据集增长,例如第二天我的数据集是testdata1和testdata2,那么如何将新数据(即"testdata2")附加到"ip_country"配置单元表中.

How to append the records to existing partitioned Hive table? For example I have existing external Table called "ip_country" and dataset is testdata1. If dataset grows say like my dataset in next day is testdata1 and testdata2 then how to append new data i.e.., "testdata2" to "ip_country" hive table.

推荐答案

可以通过两种方式实现(完全取决于您的要求)

It can be achieved in couple of ways (Purely depends on your requirement)

  1. 如果您不必担心覆盖分区中的现有记录(我的意思是您没有大量的历史数据,比如说10年的数据),那么插入覆盖可能合适.
  1. If you don't bother about overwriting the existing records in the partition, (I mean you don't have a big history data, say 10 yrs data), then Insert Overwrite might fit.

INSERT OVERWRITE TABLE tablename1 [PARTITION(partcol1 = val1, partcol2 = val2 ...)[如果不存在] select_statement1 FROM from_statement;

INSERT OVERWRITE TABLE tablename1 [PARTITION (partcol1=val1, partcol2=val2 ...) [IF NOT EXISTS]] select_statement1 FROM from_statement;

  1. 如果您不必担心分区中的重复项,那么可以插入到其中(老实说,我不希望有重复的记录).

INSERT INTO TABLE tablename1 [PARTITION(partcol1 = val1,partcol2 = val2 ...)] select_statement1 FROM from_statement;

INSERT INTO TABLE tablename1 [PARTITION (partcol1=val1, partcol2=val2 ...)] select_statement1 FROM from_statement;

  1. 如果您具有历史记录数据和增量数据,则可以插入一次历史记录数据,并可以使用插入覆盖"来插入增量数据(基于您每天/每周/每两周一次选择的频率)

这篇关于如何将新数据追加到现有的配置单元表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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