当前位置:网站首页>lateral view explode的另一种实现方式
lateral view explode的另一种实现方式
2022-08-09 09:12:00 【不爱研究的研究僧】
lateral view explode实现结果:

如果不用lateral view explode,可以这样实现:
步骤:
1.将一条记录变成n条一样的记录,即

前面再带上序号值,num是key,answers[num]即为所要的value,

2. 上图的实现通过两表连接的方式,

3.B表的实现就是生成递增数字,利用space得到n个空格,在对应空格前加上序号
--方法1
select
row_number() over() as id
from
(select split(space(299), ' ') as x) t
lateral view explode(x) ex;
--方法2
select pos + 1
from
(select 1 as id_start, 300 as id_end) t
lateral view posexplode(split(space(id_end - id_start), ' ')) ex as pos, blank;posexplode(数组) t as pos, blank,只有第一个字段有值,是位置,第二个为空,如果是map就有值
边栏推荐
猜你喜欢

Anaconda4.8.3介绍、安装及使用教程安装(win10)并修改Jupyter默认工作目录

RESTful

UE4 RTS frame selection function implementation

【场景化解决方案】构建设备通讯录,制造业设备上钉实现设备高效管理

JMeter初探五-配置元件与参数化

【培训课程专用】RPC模型:代码导读

The difference between big-endian and little-endian storage is easy to understand at a glance

历史遗留问题

The 5th Blue Cap Cup preliminary misc reappears after the game
![[V&N2020 Open] Memory Forensics](/img/b7/20f72a40d43a402009e9451903615b.png)
[V&N2020 Open] Memory Forensics
随机推荐
AES/ECB/PKCS5Padding encryption and decryption
【环境搭建】tensorrt
RESTful
Redis高可用
UE4 RTS frame selection function implementation
政务中心导航定位系统,让高效率办事成为可能
【场景化解决方案】钉钉财务审批同步金蝶云星空
Redis Basics
MySQL indexes
MVCC多版本并发控制
TypeScript Brief (1)
These 12 GIS software are better than the other
【Harmony OS】【ArkUI】ets开发 简易视频播放器
一篇文章带你熟悉 TCP/IP 协议(网络协议篇二)
【环境搭建】onnxruntime
Es6连续解构赋值+重命名
The era of Google Maps is over, how to view high-definition satellite image maps?
Global 19 Google Satellite Map Free View Download
SQL语言中的distinct说明
VoLTE基础自学系列 | IMS的业务触发机制