我有星期六的数据
Date col1 col2 col3
---------- ----- ----- -----
10/06/2017 1.230 2.210 1.067
我从过去3年的每个星期六都有这种数据,我需要将数据填充到日级粒度,如下所示;
Date col1 col2 col3
---------- ----- ----- -----
04/06/2017 1.230 2.210 1.067
05/06/2017 1.230 2.210 1.067
06/06/2017 1.230 2.210 1.067
07/06/2017 1.230 2.210 1.067
08/06/2017 1.230 2.210 1.067
09/06/2017 1.230 2.210 1.067
10/06/2017 1.230 2.210 1.067
答案 0 :(得分:0)
select date_add(t.dt,-pe.pos) as dt
,t.col1
,t.col2
,t.col3
from mytable t
lateral view posexplode(split(space(7 - 1),' ')) pe
;
+------------+------+------+------+
| dt | col1 | col2 | col3 |
+------------+------+------+------+
| 2017-06-10 | 1.23 | 2.21 | 1.07 |
| 2017-06-09 | 1.23 | 2.21 | 1.07 |
| 2017-06-08 | 1.23 | 2.21 | 1.07 |
| 2017-06-07 | 1.23 | 2.21 | 1.07 |
| 2017-06-06 | 1.23 | 2.21 | 1.07 |
| 2017-06-05 | 1.23 | 2.21 | 1.07 |
| 2017-06-04 | 1.23 | 2.21 | 1.07 |
+------------+------+------+------+