Hive日常工作常用语句

Hive日常工作常用语句

1、分区别没有数据写入空分区
alter table 表名 add if not exists partition(pt=‘${hiveconf:runDt}’);
举例:
ALTER TABLE dw_zhangxin.dw_newuser_source_detail_d_incr_flag add if not exists partition(pt=‘2022-03-15’);

2、分区表增加字段
alter table 表名 columns(字段名 字段类型) cascade;
举例:
alter table zx_user.temp_ly_zyy_jira440_201029_result add columns(yzm2_res993_cnt string) cascade;

3、日期(YYYY-MM-DD)和星期的转化
case when pmod(datediff(pt,‘1920-01-01’)-3,7)=1 then ‘星期一’
when pmod(datediff(pt,‘1920-01-01’)-3,7)=2 then ‘星期二’
when pmod(datediff(pt,‘1920-01-01’)-3,7)=3 then ‘星期三’
when pmod(datediff(pt,‘1920-01-01’)-3,7)=4 then ‘星期四’
when pmod(datediff(pt,‘1920-01-01’)-3,7)=5 then ‘星期五’
when pmod(datediff(pt,‘1920-01-01’)-3,7)=6 then ‘星期六’
when pmod(datediff(pt,‘1920-01-01’)-3,7)=0 then ‘星期日’
end as weekday

4、终端hive查询显示表头
set hive.cli.print.header=true;


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部