hive使用技巧(一)自动化动态分配表分区及修改hive表字段名称
Author:FuRenjie kwu
1、自动化动态分配表分区
set hive.exec.dynamic.partition.mode=nonstrict;
insert overwrite table ods.fund2hundsunlg PARTITION(day)
select distinct fromHostIp ,hundsunNodeIp,concat(substring(requestTime,0,10),' ', substring(requestTime,12,8)) , httpStatus ,responseTimes,urlpath, responseCharts ,postBody,
concat(substring(requestTime,0,4),substring(requestTime,6,2), substring(requestTime,9,2)) as day
from ods.fund2hundsunlog ;
说明:
1)set
hive.exec.dynamic.partition.mode=nonstrict; 设置表分区可动态加载
2)concat(substring(requestTime,0,4),substring(requestTime,6,2),
substring(requestTime,9,2)) as day,根据已有时间的切分来做partition
2、快速修改hive表字段名称
1) 重新创建新表
drop table ods.dratio;
create EXTERNAL table ods.dratio (
dratioId string comment "用户ID: