簡體   English   中英

我需要從分區表 (Hive) 進行備份

[英]I need to make backup from partitioned table (Hive)

我需要從超過 500 個分區的分區表中備份數據。 我的表按 date_part 分區,如“date_part = 20221101”或“date_part = 20221102”等。我需要從 20221101 到 20221130 進行 30 個分區,並復制到另一個新的備份表。

如果我這樣做:

create table <backup_table> as
select * from <data_table> where date_part between 20221101 and 20221130

在 output,我得到未分區的 <backup_table> 和 idk 是不是好方法,但我想分區的 <backup_table> 會更好。

如果我嘗試這樣做:

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;

在 output,我收到類似需要指定分區列的錯誤...

如果我 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;

我收到另一個錯誤,例如“運行查詢時出錯”或“...nonstrick 模式...”或其他錯誤。 我已經嘗試了很多 hive 設置,但它仍然不起作用:(

這就是為什么我需要你的幫助才能正確地做到這一點。

啟用動態分區並復制數據。

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM