创建一张表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 ;

结果如下:

最新文章

  1. SQL-语句实现九九乘法表
  2. spring batch部分
  3. Android四大组件
  4. LaTeX 笔记---Q&A
  5. 神奇的莫比乌斯带(mobius)
  6. protocolbuffe
  7. hdoj-2025
  8. 【Linux/Ubuntu学习1】Linux /etc 目录详解
  9. save与 merge与 saveOrUpdate的区别
  10. canvas 画钟表
  11. Java对Jar文件的操作[转]
  12. PHPsql
  13. ROS--导航、路径规划和SLAM
  14. spring cloud(服务消费者(利用feign实现服务消费及负载均衡)——初学三)
  15. [archlinux] 迁移T7从T460s到T470
  16. spark.yarn.jar和spark.yarn.archive的使用
  17. 数据库(linux)
  18. spa(单页面应用)的优缺点[转]
  19. 使用std::find_if提取序列容器的子串
  20. SQLServer和MySQL job和 event定时器的差别

热门文章

  1. py+selenium 直接给日期赋值,控制台调试报错【已解决】
  2. 《C Primer Plus(第6版)中文版》勘误
  3. vs项目依赖项黄色感叹号解决方案
  4. CF510C Fox And Names——拓扑排序练习
  5. Excel催化剂开源第8波-VSTO开发之异步调用方法
  6. Appium+python自动化(二十二)- 三个臭皮匠顶个诸葛亮-控件坐标获取(超详解)
  7. Vue的基本使用(四)
  8. 阿里云服务器连接以及centos 搭建 web java环境(linux java部署 tomcat部署)
  9. 我对微服务、SpringCloud、k8s、Istio的一些杂想
  10. Ansible CMDB