如何在hive中创建一个日期顺序在不同范围之间的表?

vhipe2zx  于 2021-06-02  发布在  Hadoop
关注(0)|答案(0)|浏览(162)

我正在尝试创建一个列为date的表,并希望按范围之间的顺序插入date。
以下是我尝试过的:

SET StartDate = '2009-01-01';
SET EndDate = '2016-06-31';

CREATE TABLE DateRangeTable(mydate DATE, qty INT);

INSERT INTO DateRangeTable VALUES (select a.Date, 0
from (
    select current_date - INTERVAL (a.a + (10 * b.a) + (100 * c.a)) DAY as Date
    from (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as a
    cross join (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as b
    cross join (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as c
) AS a where a.Date between '2019-01-01' and '2016-06-30');

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题