hive使用技巧(一)自动化动态分配表分区及修改hive表字段名称
来源:互联网 发布:手机淘宝修改地址在哪 编辑:程序博客网 时间:2024/06/16 09:10
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:用户ID:860010-2370010130,注册用户ID:860010-2370010131",
cookieId string comment "mcookie",
sex string comment "sex: 1 男, 2 女",
age string comment "age: 1 0-18, 2 19-29, 3 30-39, 4 40以上",
ppt string comment "ppt: 1 高购买力 2 中购买力 3 低购买力",
degree string comment "degree: 1 本科以下 2 本科及其以上",
favor string comment "喜好信息(不定长)",
commercial string comment "商业价值信息(不定长)"
)
comment "用户行为分析"
partitioned by(day string comment "按天的分区表字段")
STORED AS TEXTFILE
location '/dw/ods/dratio';
2)重新分配表分区的数据,无须数据移动
alter table ods.dratio add partition(day='20150507') location '/dw/ods/dratio/day=20150507';
alter table ods.dratio add partition(day='20150508') location '/dw/ods/dratio/day=20150508';
alter table ods.dratio add partition(day='20150509') location '/dw/ods/dratio/day=20150509';
alter table ods.dratio add partition(day='20150510') location '/dw/ods/dratio/day=20150510';
alter table ods.dratio add partition(day='20150511') location '/dw/ods/dratio/day=20150511';
alter table ods.dratio add partition(day='20150512') location '/dw/ods/dratio/day=20150512';
alter table ods.dratio add partition(day='20150513') location '/dw/ods/dratio/day=20150513';
alter table ods.dratio add partition(day='20150514') location '/dw/ods/dratio/day=20150514';
alter table ods.dratio add partition(day='20150515') location '/dw/ods/dratio/day=20150515';
alter table ods.dratio add partition(day='20150516') location '/dw/ods/dratio/day=20150516';
alter table ods.dratio add partition(day='20150517') location '/dw/ods/dratio/day=20150517';
alter table ods.dratio add partition(day='20150518') location '/dw/ods/dratio/day=20150518';
alter table ods.dratio add partition(day='20150519') location '/dw/ods/dratio/day=20150519';
alter table ods.dratio add partition(day='20150520') location '/dw/ods/dratio/day=20150520';
alter table ods.dratio add partition(day='20150521') location '/dw/ods/dratio/day=20150521';
- hive使用技巧(一)自动化动态分配表分区及修改hive表字段名称
- hive使用技巧(一)自动化动态分配表分区及修改hive表字段名称
- mysql修改表字段名称
- mysql 命令行修改表字段名称
- hive修改 表/分区语句
- hive修改 表/分区语句
- 修改hive表分区名称
- hive修改 表/分区语句
- hive 修改表/分区语句
- 查询oracle表字段名称
- hive-修改hive表字段的注释
- hive外部表及分区
- SQL修改表字段名
- Oracle , MySQL获取所有表名和表字段名称
- Hive使用问题及技巧
- Hive学习之修改表、分区、列
- Hive学习之修改表、分区、列
- hive内部表,修改分区名字
- Storm高级原语(三) — Trident topology
- leetcode | Next Permutation
- JAVA-DAY1
- 前端有用的网址
- 第13周项目1动物这样叫(3)
- hive使用技巧(一)自动化动态分配表分区及修改hive表字段名称
- linux 内核中 查看寄存器的值
- 第十三周项目2-形状类族的中的纯虚函数
- LeetCode -- Add Two Numbers
- /usr/libexec/gconf-sanity-check-2 退出状态256
- SAT填空题答题的两个注意事项
- oracle dual
- 杭州6个月练级完毕
- java提取svn中的log信息