Hadoop 如何将一天的数据填充到Hive中的整个星期
我有周六的数据Hadoop 如何将一天的数据填充到Hive中的整个星期,hadoop,hive,hiveql,Hadoop,Hive,Hiveql,我有周六的数据 Date col1 col2 col3 ---------- ----- ----- ----- 10/06/2017 1.230 2.210 1.067 我有过去3年中每个星期六的此类数据,我需要按照以下方式填充数据到日级粒度: Date col1 col2 col3 ---------- ----- -----
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
!! 对于日期,应使用日期类型;对于文本表示,应使用ISO格式YYYY-MM-DD!!保留字(日期)不应用作列名称
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 |
+------------+------+------+------+