hive默认分区数据问题

Hive表操作:创建、插入数据及动态分区问题
文章展示了在Hive中创建表`test_a`和`test_b`,插入数据,并通过`leftjoin`合并数据到新表`test_c`,使用动态分区插入数据。过程中遇到了null分区和数据覆盖的问题,特别是在插入新账期数据时,原有的分区数据被覆盖。

1.创建hive表,插入数据

创建test_a

create table test_a(id int,a string,p_day_id string);

insert into table test_a select 1,'a1','20230201';
insert into table test_a select 2,'a2','20230201';

创建test_b

create table test_b(id int,b string,p_day_id string,month_number int);

insert into table test_b select 1,'b1','20230201',1;
insert into table test_b select 2,'b2','20230201',null;

创建test_c合并两天数据,分区为month_number

hive> create table test_c(id int,a string,b string,p_day_id string) PARTITIONED BY(month_number int);

编写插入数据的sql

hive> select a.id,a.a,b.b,a.p_day_id,b.month_number from test_a a left join test_b b on a.id=b.id where a.p_day_id=b.p_day_id and a.p_day_id='20230201';
1       a1      b1      20230201        1
2       a2      b2 &nb

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值