Spark SQL如何生成连续的时间序列
作者:互联网
如上图,已知日期2022-01-01, 需要获得以2022-01-01为终点的10天的连续时间序列
附代码如下:
select date_add(dateadd(to_date('20220101','yyyymmdd'), 9, 'dd'), a.pos) as special_date
from (select posexplode(split(repeat(" ", datediff(to_date('20220101','yyyymmdd'),
dateadd(to_date('20220101','yyyymmdd'), 9, 'dd'))), " "))) a
标签:01,dd,date,20220101,yyyymmdd,SQL,序列,Spark,select 来源: https://www.cnblogs.com/robynn/p/15825894.html