[英]I need to make backup from partitioned table (Hive)
I need to make backup data from partitioned table which has over 500 partitions.我需要从超过 500 个分区的分区表中备份数据。 My table has partitioning by date_part like "date_part = 20221101" or "date_part = 20221102" etc. I need to take 30 partitions from 20221101 to 20221130 and make copy to another new backup-table.我的表按 date_part 分区,如“date_part = 20221101”或“date_part = 20221102”等。我需要从 20221101 到 20221130 进行 30 个分区,并复制到另一个新的备份表。
If I do something like this:如果我这样做:
create table <backup_table> as
select * from <data_table> where date_part between 20221101 and 20221130
at the output I get non-partitioned <backup_table> and idk is it good way or not but i guess partitioned <backup_table> will be more better.在 output,我得到未分区的 <backup_table> 和 idk 是不是好方法,但我想分区的 <backup_table> 会更好。
If I try to do:如果我尝试这样做:
create table <bacup_table> like <data_table>;
insert overwrite table <backup_table> partition (`date_part`)
select * from <data_table> where date_part between 20221101 and 20221130;
At the output I get error like need to specify partition columns...在 output,我收到类似需要指定分区列的错误...
If I go another way:如果我 go 另一种方式:
create table <bacup_table> like <data_table>;
insert overwrite table <backup_table> partition (`date_part`)
select field1, field2...,
date_part
from <data_table> where date_part between 20221101 and 20221130;
I get another errors like "error running query" or "...nonstrick mode..." or something else.我收到另一个错误,例如“运行查询时出错”或“...nonstrick 模式...”或其他错误。 I've tried a lot of hive settings but it still not work:(我已经尝试了很多 hive 设置,但它仍然不起作用:(
Thats why I need your help to do it correctly.这就是为什么我需要你的帮助才能正确地做到这一点。
enable dynamic partition and copy the data.启用动态分区并复制数据。
SET hive.exec.dynamic.partition = true;
SET hive.exec.dynamic.partition.mode = nonstrict;
SET hive.mapred.mode = nonstrict;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.