栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

HIVE 使用正则输出符合条件的字段

HIVE 使用正则输出符合条件的字段

HIVE 使用正则输出符合条件的字段

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' ;

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/753819.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号