select列表使用正则的小技巧(HIVE)

Hive 0.13.0之后,select列表支持正则表达式了。对于如下的应用场景

create table tb2 like tb1

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

posted @ 2015-09-08 19:28  upo  阅读(1300)  评论(0)    收藏  举报