1.一時テーブルを作成し、一時テーブルにデータを追加します
Drop table if exists test.tmp;
create table test.tmp(
shopid int,
userid int,
areaid int,
shopname string,
shoplevel tinyint,
status tinyint,
createtime string,
modifytime string,
dt string
)
row format delimited fields terminated by ',';
load data local inpath 'tmp.dat' into table test.tmp;
tmp.dat
105307,78921,100049、Rushan
xxx旗艦店、1、1、2020-06-28、2020-07-01 13:22:22、2020-07-01 105308、78921、100236、美しいxxx旗艦店、1、 1,2020-06-28,2020-07-01 13:22:22,2020-07-01
105309,78921,100063、Juxxx旗艦店、1,1,2020-06-28,2020-07-01 13 :
22 :22、2020-07-01 105310、78921、100235、Lansi xxx旗艦店、1、1、2020-06-28、2020-07-01 13 :22 :
22、2020-07-01 105311、78921 、100016、LExxx旗艦店、1,1,2020-06-28,2020-07-01 13:22:22,2020-07-01
105312,78921,100325、Meile xxx旗艦店、1,1、2020- 6月28日、2020年7月1日
午後01時22分22秒、2020年7月1日105313、78921、100285、オークXXX本店、1、1、2020年6月28日、2020年7月1日13:
22: 22、2020-07-01 105314、78921、100116、Bega xxx旗艦店、1、1、2020-06-28、2020-07-01 13:22:22、2020-07-01 105315、78921、100036
、 Caxxx認定ストア、1、1、2020-06-28、2020-07-01 13:22:22、2020-07-01
105316,78921,100143、シーザーxxx旗艦店、1、1、2020-06-28、2020-07-01 13:22:22、2020-07-01
2.パーティションテーブルを作成します
Drop table if exists test.ods_trade_shops;
create table test.ods_trade_shops(
shopid int,
userid int,
areaid int,
shopname string,
shoplevel tinyint,
status tinyint,
createtime string,
modifytime string
)
partitioned by(dt string)
row format delimited fields terminated by ',';
3.ハイブコマンドラインで動的パーティションパラメータを設定します
set hive.exec.dynamic.partition = true;-このパラメーターは、hive0.9.0バージョンからデフォルトでtrueであり、hive0.9.0以降を使用する必要はありません。
set hive.exec.dynamic.partition.mode = nonstrict;
4.パーティションテーブルのデータを動的にロードします
insert into table test.ods_trade_shops
partition(dt)
select * from test.tmp;