admin 管理员组文章数量: 1087649
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;
本文标签: Hive日常工作常用语句
版权声明:本文标题:Hive日常工作常用语句 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1700299437a386187.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论