HIVE中select除了某些字段之外的剩余所有字段
这是HIVE中查询语句的一个小技巧,一个表字段太多,我们想要除个别字段外的剩余所有字段,全部列出来看起来难受,实际上hive语句可以解决这个问题。
Hive 0.13.0之后,select列表支持正则表达式了
insert overwrite table tb2 partition(dt=xx, hr=xx) select * from tb1 是不行的,因为后者是N个列,前者是N-2个列
以前的做法
insert overwrite table tb2 partition(dt=xx, hr=xx) select c1, c2, c3, c4… from tb1
现在可以采用,前提是
set hive.support.quoted.identifiers=none
insert overwrite table tb2 partition(dt=xx, hr=xx) select `(dt|hr)?+.+` from tb1

本文介绍Hive 0.13.0版本后引入的新特性:使用正则表达式进行选择操作。通过示例展示如何排除特定字段,选取其余所有字段的方法,简化复杂查询。
1828

被折叠的 条评论
为什么被折叠?



