当前位置:网站首页>【HQL】(二) 查询使用正则表达式做列选择
【HQL】(二) 查询使用正则表达式做列选择
2022-08-03 05:22:00 【cbigchaos】
工作中遇到这样的场景:查询时少数列不需要,需要的其余列数量又较多
Hive 0.13.0之后,select列表支持正则表达式了
查询时使用SELECT语句的时候采用正则表达式做列选择
废话不多说上例子
原表数据:
hive> select * from tab1;
OK
user_id opration log_time
1 A 2019/5/1
1 A 2019/5/2
1 A 2019/5/3
2 A 2019/5/1
2 A 2019/5/3
2 A 2019/5/7
2 A 2019/5/31
3 A 2019/5/1
3 A 2019/5/2
Time taken: 0.046 seconds, Fetched: 10 row(s)
查询除个别字段外的剩余所有字段
PS:使用这个技巧需要设定一个参数set hive.support.quoted.identifiers=none
select `(user_id)?+.+` from tab1;
结果:
踩了个坑
未设定参数导致报错
hive> select `(user_id)?+.+` from tab1;
FAILED: SemanticException [Error 10004]: Line 1:7 Invalid table alias or column
reference '(user_id)?+.+': (possible column names are: user_id, opration, log_time)
在spark SQL中加参数
set spark.sql.parser.quotedRegexColumnNames=true
参考:https://blog.csdn.net/qq_29232943/article/details/79462381
边栏推荐
猜你喜欢
随机推荐
私有变量(private) 【详细+易懂】
7.7(5)
用户登录验证程序的实现
【Arduino】关于“&”和“|” 运算-----多个参数运算结果异常的问题解决
处理异步事件的三种方式
Browser multi-threaded off-screen rendering, compression and packaging scheme
The ` monorepo ` ` hoist ` mechanism lead to the change of the loading configuration file path
令人愉快的 Nuxt3 教程 (二): 快速轻松地搭建博客
【Nmap与Metasploit常用命令】
Greetings(状压DP,枚举子集转移)
浏览器中的 preview 和 response 的值不一致
7.15(6)
D-PHY
MySQL 索引详解和什么时候创建索引什么时候不适用索引
1230: 蜂巢
7.17(7)
【 command execution and middleware loopholes 】
小码农的第一篇博客
Leetcode刷题——一些用层次遍历解决的问题(111. 二叉树的最小深度、104. 二叉树的最大深度、226. 翻转二叉树、剑指 Offer 27. 二叉树的镜像)
Go (一) 基础部分2 -- if条件判断,for循环语句









