hive生成連續的時間和連續的數

大鹏的鸿鹄之志發表於2024-10-12
select 
*,
DATE_ADD(t_start, n) AS pt
from (
SELECT 
    22 as uid
    ,'2024-10-01'as  t_start
    ,'2024-10-05'as  t_end
,11 as hh )t LATERAL
VIEW posexplode(split(space(DATEDIFF(t_end, t_start)), ' ')) k AS n,


22 2024-10-01 2024-10-05 11 0 2024-10-01
22 2024-10-01 2024-10-05 11 1 2024-10-02
22 2024-10-01 2024-10-05 11 2 2024-10-03
22 2024-10-01 2024-10-05 11 3 2024-10-04
22 2024-10-01 2024-10-05 11 4 2024-10-05

相關文章