Use particiones dinámicas para cargar datos para la tabla de particiones en Hive

1. Cree una tabla temporal, agregue datos a la tabla temporal

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,
tienda insignia Rushan xxx, 1, 1, 2020-06-28, 2020-07-01 13:22:22, 2020-07-01 105308, 78921, 100236, hermosa tienda insignia xxx, 1, 1,2020-06-28,2020-07-01 13: 22: 22,2020-07-01
105309,78921,100063, tienda insignia Juxxx, 1,1,2020-06-28,2020-07-01 13 :
22:22, 2020-07-01 105310, 78921, 100235, tienda insignia Lansi xxx, 1, 1, 2020-06-28, 2020-07-01
13:22:22, 2020-07-01 105311, 78921 , 100016, tienda insignia LExxx, 1,1,2020-06-28,2020-07-01 13: 22: 22,2020-07-01
105312,78921,100325, tienda insignia Meile xxx, 1,1, 2020- 06-28, 2020-07-01
13:22:22, 2020-07-01 105313, 78921, 100285, tienda insignia Oak xxx, 1, 1, 2020-06-28, 2020-07-01 13:
22: 22, 2020-07-01 105314, 78921, 100116, tienda insignia Bega xxx, 1, 1, 2020-06-28, 2020-07-01
13:22:22, 2020-07-01 105315, 78921, 100036, Tienda autorizada Caxxx, 1, 1, 2020-06-28, 2020-07-01 13:22:22, 2020-07-01
105316,78921,100143, tienda insignia Caesar xxx, 1, 1, 2020-06-28, 2020-07-01 13:22:22, 2020-07-01

2. Crea una tabla de particiones

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. Establecer parámetros de partición dinámica en la línea de comando de la colmena

set hive.exec.dynamic.partition = true; --Este parámetro es true por defecto desde la versión hive0.9.0, y no es necesario usar hive0.9.0 y superior

establecer hive.exec.dynamic.partition.mode = nonstrict;

4. Cargue datos dinámicamente para la tabla de particiones

insert into table test.ods_trade_shops
partition(dt)
select * from test.tmp;

 

Supongo que te gusta

Origin blog.csdn.net/abc5254065/article/details/112948224
Recomendado
Clasificación