gpt4 book ai didi

hadoop - 配置单元将数据从一个分区复制到另一个分区

转载 作者:行者123 更新时间:2023-12-02 22:06:27 24 4
gpt4 key购买 nike

我有一个按日期分区的配置单元表。我有日期“2020-08-18”的数据。我想将相同的数据复制(复制)到另一个分区。
有这样的命令吗

SELECT * FROM table_a WHERE date = "2020-08-18" INTO table_a WHERE date = "2020-08-10" 

最佳答案

以下查询可能对您有帮助,

INSERT OVERWRITE TABLE table_a PARTITION (odate="2020-08-18") 
select empdate,empvalue from table_a where odate='2020-08-10';
注意:不要在select语句中包括partition列。
create table if not exists table_a (empdate string, empvalue string) PARTITIONED BY 
(odate string) row format delimited fields terminated by ',' stored as textfile;

INSERT OVERWRITE TABLE table_a PARTITION (odate="2020-08-10")
values ('101001','A'),('200101','B'),('100619','C'),('110707','D');

hive> select * from table_a;
OK
101001 A 2020-08-10
200101 B 2020-08-10
100619 C 2020-08-10
110707 D 2020-08-10

-- dont include the odate column in the select statement otherwise it will lead
-- to Cannot insert into target table because column number/types are different
-- '"2020-08-18"': Table insclause-0 has 2 columns, but query has 3 columns error.


INSERT OVERWRITE TABLE table_a PARTITION (odate="2020-08-18")
select empdate,empvalue from table_a where odate='2020-08-10';

hive> select * from table_a;
OK
101001 A 2020-08-10
200101 B 2020-08-10
100619 C 2020-08-10
110707 D 2020-08-10
101001 A 2020-08-18
200101 B 2020-08-18
100619 C 2020-08-18
110707 D 2020-08-18

关于hadoop - 配置单元将数据从一个分区复制到另一个分区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63475714/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com