HIVE 查询除了其中某个字段剩余所有字段
无意中了解到 HIVE 中可以使用正则来实现匹配符合条件的列,特此记录,文档如下:
hive.support.quoted.identifiers
HIVE 查询除了其中某个字段剩余所有字段create table if not exists user_temp
(
user_id string comment '用户ID',
user_name string comment '用户姓名',
emp_id string comment '部门ID'
)
comment '客户信息表'
partitioned by (ds string)
stored as orc tblproperties ('orc.compress'='SNAPPY')
;
① 查询除了 user_id 剩余的其他字段
set hive.support.quoted.identifiers=None; select `(user_id)?+.+` from user_temp where ds = '20220222' ;
② 查询除了 user_id、ds 剩余的其他字段
set hive.support.quoted.identifiers=None; select `(user_id|ds)?+.+` from user_temp where ds = '20220222' ;
③ 查询字段以 ’id 为后缀的字段
set hive.support.quoted.identifiers=None; select `.+id` from user_temp where ds = '20220222' ;
④ 查询字段以 user 开头的
set hive.support.quoted.identifiers=None; select `user+.+` from user_temp where ds = '20220222' ;



