[英]How to populate one day of data to entire week in Hive
我有星期六的数据
Date col1 col2 col3
---------- ----- ----- -----
10/06/2017 1.230 2.210 1.067
我拥有过去三年中每个星期六的此类数据,我需要将数据填充为以下级别的日级粒度:
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
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 |
+------------+------+------+------+
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.