hive explode 行拆列
2024-09-01 02:48:57
创建一张表test_explode,表结构如下
表数据如下:
1.使用explode函数
select explode(friends) as friend from test_explode;
但是只使用explode函数很难满足实际需求,原因如下:
1.1 No other expressions are allowed in SELECT
0: jdbc:hive2://master01.hadoop.mobile.cn:1> select name,explode(friends) as friend from test_explode; Error: Error while compiling statement: FAILED: SemanticException [Error 10081]: UDTF's are not supported outside the SELECT clause, nor nested in expressions (state=42000,code=10081)
1.2 UDTF's can't be nested
1.3 GROUP BY / CLUSTER BY / DISTRIBUTE BY / SORT BY is not supported
2 配合LATERAL VIEW 解除限制
select name,sex,phone,friend from test_explode LATERAL VIEW explode(friends) myTable1 AS friend ;
结果如下:
最新文章
- SQL-语句实现九九乘法表
- spring batch部分
- Android四大组件
- LaTeX 笔记---Q&;A
- 神奇的莫比乌斯带(mobius)
- protocolbuffe
- hdoj-2025
- 【Linux/Ubuntu学习1】Linux /etc 目录详解
- save与 merge与 saveOrUpdate的区别
- canvas 画钟表
- Java对Jar文件的操作[转]
- PHPsql
- ROS--导航、路径规划和SLAM
- spring cloud(服务消费者(利用feign实现服务消费及负载均衡)——初学三)
- [archlinux] 迁移T7从T460s到T470
- spark.yarn.jar和spark.yarn.archive的使用
- 数据库(linux)
- spa(单页面应用)的优缺点[转]
- 使用std::find_if提取序列容器的子串
- SQLServer和MySQL job和 event定时器的差别
热门文章
- py+selenium 直接给日期赋值,控制台调试报错【已解决】
- 《C Primer Plus(第6版)中文版》勘误
- vs项目依赖项黄色感叹号解决方案
- CF510C Fox And Names——拓扑排序练习
- Excel催化剂开源第8波-VSTO开发之异步调用方法
- Appium+python自动化(二十二)- 三个臭皮匠顶个诸葛亮-控件坐标获取(超详解)
- Vue的基本使用(四)
- 阿里云服务器连接以及centos 搭建 web java环境(linux java部署 tomcat部署)
- 我对微服务、SpringCloud、k8s、Istio的一些杂想
- Ansible CMDB