当前位置:网站首页>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就有值
边栏推荐
猜你喜欢
随机推荐
关于指针、地址的大小的问题(以及malloc的用法)
canvas 文字垂直居中
Difference: char* and char[]
uniapp编译到小程序后丢失static文件夹问题
小程序/app触底加载更多数据
Read file by byte and character_load configuration file
sizeof 结构体问题
没有对象的可以进来看看, 这里有对象介绍
BUUCTF MISC brush notes (2)
二叉树的遍历(非递归)
Anaconda4.8.3介绍、安装及使用教程安装(win10)并修改Jupyter默认工作目录
【环境搭建】onnxruntime
on duplicate key update
RESTful
【场景化解决方案】构建设备通讯录,制造业设备上钉实现设备高效管理
MySQL Leak Check (4) Stored Procedures and Cursors
PoPW token distribution mechanism may ignite the next bull market
CPU主频 外频 芯片组 倍频 cache FSB PCI简介
政务中心导航定位系统,让高效率办事成为可能
convert转换时间详解









